Merge lp:~nacl/wicd/1.6-urwid-0.9.9-compat into lp:wicd/1.6

Proposed by Andrew Psaltis
Status: Rejected
Rejected by: Adam Blackburn
Proposed branch: lp:~nacl/wicd/1.6-urwid-0.9.9-compat
Merge into: lp:wicd/1.6
Diff against target: 1050 lines (+450/-205)
6 files modified
curses/curses_misc.py (+1/-1)
curses/netentry_curses.py (+4/-7)
curses/popup.py (+312/-0)
curses/prefs_curses.py (+19/-16)
curses/wicd-curses.py (+113/-181)
setup.py (+1/-0)
To merge this branch: bzr merge lp:~nacl/wicd/1.6-urwid-0.9.9-compat
Reviewer Review Type Date Requested Status
Adam Blackburn Disapprove
Review via email: mp+15096@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Andrew Psaltis (nacl) wrote :

These are changes to wicd 1.6 that make wicd-curses more compatible with urwid 0.9.9. These changes break compatibility with urwid 0.9.8.*, and should be included in mainline once urwid 0.9.9 is mainstream in all major distributions.

lp:~nacl/wicd/1.6-urwid-0.9.9-compat updated
353. By Andrew Psaltis

Added support for the new and improved DropDown that is based on Ian Ward's PopUpTarget.

354. By Andrew Psaltis

Trimmed some stuff.

355. By Andrew Psaltis

Pad the wpa driver DropDown correctly.

356. By Andrew Psaltis

Moved the padding code over to the DropDown itself and cleaned up some stuff.

357. By Andrew Psaltis

Added callback support to the DropDown and replaced the remaining ComboBoxes
in the big dialogs.

358. By Andrew Psaltis

Fix bug preventing mouse from working with the OptCols.

Revision history for this message
Andrew Psaltis (nacl) wrote :

> These are changes to wicd 1.6 that make wicd-curses more compatible with urwid
> 0.9.9. These changes break compatibility with urwid 0.9.8.*, and should be
> included in mainline once urwid 0.9.9 is mainstream in all major
> distributions.

This code went unstable the last time I modified it, so don't even try to merge it until
the new DropDowns are implemented.

Revision history for this message
Adam Blackburn (adamblackburn) wrote :

Didn't look at the code, but we've decided not to merge this for 1.7.

review: Disapprove

Unmerged revisions

358. By Andrew Psaltis

Fix bug preventing mouse from working with the OptCols.

357. By Andrew Psaltis

Added callback support to the DropDown and replaced the remaining ComboBoxes
in the big dialogs.

356. By Andrew Psaltis

Moved the padding code over to the DropDown itself and cleaned up some stuff.

355. By Andrew Psaltis

Pad the wpa driver DropDown correctly.

354. By Andrew Psaltis

Trimmed some stuff.

353. By Andrew Psaltis

Added support for the new and improved DropDown that is based on Ian Ward's PopUpTarget.

352. By Andrew Psaltis

Fixed up the optcols, apparently, I dropped something. :P

351. By Andrew Psaltis

Merge mainline r463.

350. By Andrew Psaltis

Merge local formatting/print statement removal changes that didn't seem to make it.

349. By Andrew Psaltis

Merge r461 of mainline, providing some bugfixes (some wicd-curses stuff ignored).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'curses/curses_misc.py'
--- curses/curses_misc.py 2009-09-29 16:38:11 +0000
+++ curses/curses_misc.py 2009-11-21 05:36:12 +0000
@@ -547,7 +547,7 @@
547 def mouse_event(self,size,event,button,x,y,focus):547 def mouse_event(self,size,event,button,x,y,focus):
548 if event == "mouse press":548 if event == "mouse press":
549 # The keypress dealie in wicd-curses.py expects a list of keystrokes549 # The keypress dealie in wicd-curses.py expects a list of keystrokes
550 self.callback([self.args])550 self.callback([self.args],size=None)
551551
552# htop-style menu menu-bar on the bottom of the screen552# htop-style menu menu-bar on the bottom of the screen
553class OptCols(urwid.WidgetWrap):553class OptCols(urwid.WidgetWrap):
554554
=== modified file 'curses/netentry_curses.py'
--- curses/netentry_curses.py 2009-07-19 02:18:21 +0000
+++ curses/netentry_curses.py 2009-11-21 05:36:12 +0000
@@ -23,6 +23,7 @@
2323
24import urwid24import urwid
25from curses_misc import TextDialog,DynWrap,MaskingEdit,ComboBox,error25from curses_misc import TextDialog,DynWrap,MaskingEdit,ComboBox,error
26from popup import DropDown
26import wicd.misc as misc27import wicd.misc as misc
27from wicd.misc import noneToString, stringToNone, noneToBlankString, to_bool28from wicd.misc import noneToString, stringToNone, noneToBlankString, to_bool
2829
@@ -95,7 +96,6 @@
9596
9697
97 self._listbox = urwid.ListBox(walker)98 self._listbox = urwid.ListBox(walker)
98 #self._frame = urwid.Frame(self._listbox)
99 self._frame = urwid.Frame(self._listbox)99 self._frame = urwid.Frame(self._listbox)
100 self.__super.__init__(self._frame)100 self.__super.__init__(self._frame)
101 101
@@ -207,7 +207,6 @@
207 AdvancedSettingsDialog.save_settings(self)207 AdvancedSettingsDialog.save_settings(self)
208 if self.set_default.get_state():208 if self.set_default.get_state():
209 wired.UnsetWiredDefault()209 wired.UnsetWiredDefault()
210 print self.set_default.get_state()
211 if self.set_default.get_state():210 if self.set_default.get_state():
212 bool = True211 bool = True
213 else:212 else:
@@ -236,7 +235,7 @@
236 235
237 self.global_settings_chkbox = urwid.CheckBox(global_settings_t)236 self.global_settings_chkbox = urwid.CheckBox(global_settings_t)
238 self.encryption_chkbox = urwid.CheckBox(encryption_t,on_state_change=self.encryption_toggle)237 self.encryption_chkbox = urwid.CheckBox(encryption_t,on_state_change=self.encryption_toggle)
239 self.encryption_combo = ComboBox(callback=self.combo_on_change)238 self.encryption_combo = DynWrap(DropDown(callback=self.combo_on_change))#ComboBox(callback=self.combo_on_change)
240 self.autoconnect_chkbox = urwid.CheckBox(autoconnect_t)239 self.autoconnect_chkbox = urwid.CheckBox(autoconnect_t)
241 self.pile_encrypt = None240 self.pile_encrypt = None
242 # _w is a Frame, _w.body is a ListBox, _w.body.body is the ListWalker :-)241 # _w is a Frame, _w.body is a ListBox, _w.body.body is the ListWalker :-)
@@ -255,7 +254,7 @@
255 self.encryption_combo.set_sensitive(new_state)254 self.encryption_combo.set_sensitive(new_state)
256 self.pile_encrypt.set_sensitive(new_state)255 self.pile_encrypt.set_sensitive(new_state)
257256
258 def combo_on_change(self,combobox,new_index,user_data=None):257 def combo_on_change(self,lb,user_data=None):
259 self.change_encrypt_method()258 self.change_encrypt_method()
260259
261 def set_values(self):260 def set_values(self):
@@ -318,7 +317,6 @@
318 def save_settings(self):317 def save_settings(self):
319 # Check encryption info318 # Check encryption info
320 if self.encryption_chkbox.get_state():319 if self.encryption_chkbox.get_state():
321 #print "setting encryption info..."
322 encrypt_info = self.encryption_info320 encrypt_info = self.encryption_info
323 encrypt_methods = self.encrypt_types321 encrypt_methods = self.encrypt_types
324 self.set_net_prop("enctype",322 self.set_net_prop("enctype",
@@ -395,10 +393,9 @@
395 # Make this into a listbox?393 # Make this into a listbox?
396 self.pile_encrypt = DynWrap(urwid.Pile(theList),attrs=('editbx','editnfc'))394 self.pile_encrypt = DynWrap(urwid.Pile(theList),attrs=('editbx','editnfc'))
397 self._w.body.body.insert(self._w.body.body.__len__(),self.pile_encrypt)395 self._w.body.body.insert(self._w.body.body.__len__(),self.pile_encrypt)
398 #self._w.body.body.append(self.pile_encrypt)
399396
400 def ready_widgets(self,ui,body):397 def ready_widgets(self,ui,body):
401 self.ui = ui398 self.ui = ui
402 self.body = body399 self.body = body
403 self.encryption_combo.build_combobox(body,ui,14)400 #self.encryption_combo.build_combobox(body,ui,14)
404 self.change_encrypt_method()401 self.change_encrypt_method()
405402
=== added file 'curses/popup.py'
--- curses/popup.py 1970-01-01 00:00:00 +0000
+++ curses/popup.py 2009-11-21 05:36:12 +0000
@@ -0,0 +1,312 @@
1#!/usr/bin/env python
2
3# Much of this code has been placed into the public domain by its original
4# author and urwid maintainer, Ian Ward. A very big thanks to him for making
5# this available to me, it's going to make greatly simplify the wicd-curses
6# code and make things easier for wicd-curses 2.0 when I actually start working
7# on it. Urwid in general is fun to work with, and has proven to be a very
8# robust library.
9#
10# ~ Andrew
11
12# NOTE:
13# While much of this file is in the PUBLIC DOMAIN, the DropDown class is
14# licensed under the GNU General Public License, Version 2 or higher.
15#
16# Standard License statement follows:
17# Copyright (C) 2009 Andrew Psaltis
18
19# This file is a part of wicd.
20#
21# Wicd is free software; you can redistribute it and/or modify
22# it under the terms of the GNU General Public License as published by
23# the Free Software Foundation; either version 2 of the License, or
24# (at your option) any later version.
25#
26# This program is distributed in the hope that it will be useful,
27# but WITHOUT ANY WARRANTY; without even the implied warranty of
28# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29# GNU General Public License for more details.
30#
31# You should have received a copy of the GNU General Public License
32# along with this program; if not, write to the Free Software
33# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
34# MA 02110-1301, USA.
35
36import urwid
37import urwid.raw_display
38import sys
39from curses_misc import SelText
40
41### BEGIN PUBLIC DOMAIN CODE ###
42class PopUpTarget(urwid.WidgetWrap):
43 def __init__(self, original_widget):
44 self.__super.__init__(original_widget)
45 self._pop_up = None
46 self._current_widget = self._w
47
48 def render(self, size, focus=False):
49 canv = self._current_widget.render(size, focus=focus)
50 if 'pop_up' in canv.coords:
51 x, y, (w, h, widget, set_close) = canv.coords['pop_up']
52 if not self._pop_up:
53 self._open_pop_up(x, y, w, h, widget)
54 set_close(self.close_pop_up)
55 else:
56 self._update_pop_up(x, y, w, h)
57 canv = self._current_widget.render(size, focus=focus)
58
59 return canv
60
61 def _open_pop_up(self, x, y, w, h, widget):
62 assert not self._pop_up
63 self._pop_up = widget
64 self._update_pop_up(x, y, w, h)
65
66 def _update_pop_up(self, x, y, w, h):
67 self._current_widget = urwid.Overlay(self._pop_up, self._w,
68 ('fixed left', x), w, ('fixed top', y), h)
69
70 def close_pop_up(self):
71 if self._pop_up:
72 self._pop_up = None
73 self._current_widget = self._w
74 self._invalidate()
75
76 # use our current widget's methods
77 selectable = property(lambda self:self._current_widget.selectable)
78 get_cursor_coords = property(lambda self:self._current_widget.get_cursor_coords)
79 get_pref_col = property(lambda self:self._current_widget.get_pref_col)
80 keypress = property(lambda self:self._current_widget.keypress)
81 move_cursor_to_coords = property(lambda self:self._current_widget.move_cursor_to_coords)
82 mouse_event = property(lambda self:self._current_widget.mouse_event)
83 sizing = property(lambda self:self._current_widget.sizing)
84
85### BEGIN GPL CODE ###
86class DropDown(urwid.WidgetWrap):
87 def __init__(self,items=[],show_indicator=True,popup_attr='body',popup_f_attr='focus',callback=None,user_args=None):
88 self._popup_attr = popup_attr
89 self._popup_f_attr = popup_f_attr
90 self.callback = callback
91 self.user_args = user_args
92 self.set_list(items,init=True)
93 self.lb = urwid.ListBox(self._walker)
94
95 if len(self._walker) != 0:
96 self.text = self.lb.get_focus()[0].base_widget
97 else:
98 self.text = SelText("")
99 self._open_pop_up = False
100 if show_indicator:
101 self._cols = urwid.Columns([self.text,('fixed',3,urwid.Padding(urwid.Text('[V]'),'right',3))],dividechars=1)
102 self.__super.__init__(urwid.Padding(self._cols,'left',self._maxlen+4))
103 else:
104 self._cols = urwid.Columns([self.text])
105 self.__super.__init__(urwid.Padding(self._cols,'left',self._maxlen))
106
107 def get_popup_attr(self):
108 return self._popup_attr
109 def get_popup_f_attr(self):
110 return self._popup_f_attr
111
112 def set_popup_attr(self,attr):
113 self._popup_attr = attr
114 def set_popup_f_attr(self,attr):
115 self._popup_f_attr = attr
116
117 def remove(self,text):
118 """
119 Remove the first item with text "text" from the DropDown.
120
121 Returns the text if it's in the DropDown, None otherwise
122
123 >>> d = DropDown(['one','rediculously','long','string'])
124 >>> d._maxlen
125 12
126 >>> len('rediculously')
127 12
128 >>> d.remove('rediculously')
129 'rediculously'
130 >>> d._maxlen
131 6
132 >>> d.remove('rediculously')
133 None
134 """
135 swap_out = False
136 for txt in self._walker:
137 if txt.text == text:
138 if self.lb.get_focus()[0] == txt:
139 swap_out = True
140 self._walker.remove(txt)
141 if txt.base_widget.pack()[0] == self._maxlen:
142 self._adjust_and_align()
143 if swap_out:
144 self._cols.widget_list[0] = self.lb.get_focus()[0].base_widget
145 return text
146 return None
147
148 def _align(self):
149 self._maxlen = 0
150 #print >> sys.stderr, "len walker:",len(self._walker)
151 for i in self._walker:
152 #print >>sys.stderr, i.base_widget.pack()[0]
153 if self._maxlen < i.base_widget.pack()[0]:
154 #print >>sys.stderr, "New maxlen is '%s'" % i.text
155 self._maxlen = i.base_widget.pack()[0]
156
157 def _adjust_and_align(self):
158 #print >> sys.stderr, "ADJUST_AND_ALIGN"
159 #print >> sys.stderr, "width is", self._w.width
160 self._w.width -= self._maxlen
161 #print >> sys.stderr, "maxlen is", self._maxlen
162 #print >> sys.stderr, "width is", self._w.width
163 self._align()
164 self._w.width += self._maxlen
165 #print >> sys.stderr, "width is", self._w.width
166
167 def get_focus(self):
168 """
169 Get the current focus of the widget.
170
171 """
172 return self.lb.get_focus()
173 def set_focus(self,idx):
174 self.lb.set_focus(idx)
175 focus = property(get_focus,set_focus)
176
177 def size(self):
178 return len(self._walker)
179
180 def set_list(self,l,init=False):
181 itexts = [urwid.AttrWrap(SelText(i),self._popup_attr,self._popup_f_attr) for i in l]
182 self._walker = urwid.SimpleListWalker(itexts)
183 if init:
184 self._align()
185 # Do additional stuff if this is not called from the constructor
186 else:
187 #print >>sys.stderr,"ddown says", self._w.width
188 self.lb.body = self._walker
189 self._adjust_and_align()
190 if len(self._walker) != 0:
191 self._cols.widget_list[0] = self.lb.get_focus()[0].base_widget
192 else:
193 self._cols.widget_list[0] = SelText("")
194 #print >>sys.stderr,"ddown says", self._w.width
195
196
197 def append_list(self,l):
198 for i in l:
199 self.append_item(i)
200 return True
201
202 def append_item(self,text):
203 return self.insert_item(text,len(self._walker))
204
205 def insert_item(self,text,idx):
206 """
207 Inserts a new item with text 'text' at index 'idx' by calling the
208 'insert' method of the DropDown's ListWalker.
209
210 This raises an IndexError if 'idx' is greater than the length of the
211 list, but negative indices are accepted (and are actually used as the
212 default value for idx). Be careful!
213
214 This also raises a TypeError if idx is not an integer
215
216 Return value: True
217 """
218 if idx > len(self._walker):
219 raise IndexError("Index '%d' out of listwalker bounds" % idx)
220 if type(idx) != type(0):
221 raise TypeError("Index is of type %s, not an integer" % type(idx))
222 wid = SelText(text)
223 self._walker.insert(idx,urwid.AttrWrap(wid,self._popup_attr,self._popup_f_attr))
224 if len(self._walker) == 1:
225 self._cols.widget_list[0] = self.lb.get_focus()[0].base_widget
226 if wid.pack()[0] > self._maxlen:
227 self._w.width -= self._maxlen
228 self._maxlen = wid.pack()[0]
229 self._w.width += self._maxlen
230
231 return True
232
233 def _create_pop_up(self):
234 class CPane(urwid.Frame):
235 def __init__(self,body,callback):
236 self.callback = callback
237 self.__super.__init__(urwid.LineBox(body))
238 def keypress(self,size,key):
239 self.get_body().keypress(size,key)
240 if key in [ 'enter' ]:
241 self.do_close()
242 self.callback()
243 if key in [ 'esc' ]:
244 self.do_close()
245 self.callback(False)
246 def callback(save=True):
247 if save:
248 self.sel_item,self.sel_index = self.lb.get_focus()
249 self._cols.widget_list[0] = self.sel_item
250 if self.callback != None:
251 self.callback(self.lb,self.user_args)
252 self._open_pop_up = False
253 self._invalidate()
254 popup_frame = CPane(self.lb,callback)
255
256 def set_close(fn):
257 popup_frame.do_close = fn
258 return (self._maxlen+2,len(self._walker)+2,popup_frame,set_close)
259
260 def render(self, size, focus=False):
261 canv = self.__super.render(size, focus)
262 if self._open_pop_up:
263 canv = urwid.CompositeCanvas(canv)
264 # same left column, one line below ourselves
265 canv.coords['pop_up'] = (0, 1, self._pop_up_window)
266 return canv
267
268 def keypress(self,size,key):
269 if key in [ "enter", ' ' ]:
270 self._pop_up_window = self._create_pop_up()
271 self._open_pop_up = True
272 self._invalidate()
273 return key
274
275ui = urwid.raw_display.Screen()
276ui.register_palette([('popbg', 'white', 'dark blue'),
277 ('body','light gray','black'),
278 ('focus','black','light gray')])
279
280def run():
281 size = ui.get_cols_rows()
282 l = ['zero','one','two','three','really_long_item']
283 #d = DropDown(l)
284 d = urwid.AttrWrap(DropDown(l),'body','popbg')
285 #d = DropDown()
286 fill = urwid.Filler(urwid.Padding(urwid.Columns([urwid.Text("Press space:"),d]), 'center', 40))
287 #fill = urwid.Filler(ComboBox())
288 target = PopUpTarget(fill)
289 #print >>sys.stderr, d._maxlen
290 #print >>sys.stderr, d._w.width
291 i = 4
292 while True:
293 canvas = target.render(size, True)
294 ui.draw_screen(size, canvas)
295
296 keys = ui.get_input()
297 if "c" in keys:
298 d.remove(l[i])
299 i-=1
300 for k in keys:
301 target.keypress(size, k)
302 if "window resize" in keys:
303 size = ui.get_cols_rows()
304
305
306if __name__ == '__main__':
307 if len(sys.argv) > 1 and sys.argv[1] == "test":
308 import doctest
309 doctest.testmod()
310 else:
311 ui.run_wrapper(run)
312### END GPL CODE ###
0313
=== modified file 'curses/prefs_curses.py'
--- curses/prefs_curses.py 2009-10-31 03:52:30 +0000
+++ curses/prefs_curses.py 2009-11-21 05:36:12 +0000
@@ -21,7 +21,9 @@
2121
22import urwid22import urwid
23import urwid.curses_display23import urwid.curses_display
24from popup import DropDown
2425
26import sys
25from wicd import misc27from wicd import misc
26from wicd import dbusmanager28from wicd import dbusmanager
27from curses_misc import SelText,DynWrap,DynRadioButton,ComboBox,TabColumns29from curses_misc import SelText,DynWrap,DynRadioButton,ComboBox,TabColumns
@@ -216,11 +218,15 @@
216218
217 #### Advanced settings219 #### Advanced settings
218 self.wpa_cat = urwid.Text(wpa_cat_t)220 self.wpa_cat = urwid.Text(wpa_cat_t)
219 self.wpa_cbox = ComboBox(wpa_t)221 self.wpa_ddown = DropDown()
222 wpa_txt = urwid.Text(wpa_t)
223 self.wpa_cols = urwid.Columns([('fixed',wpa_txt.pack()[0],wpa_txt),urwid.AttrWrap(self.wpa_ddown,'body','focus')])
220 self.wpa_warn = urwid.Text(wpa_warn_t)224 self.wpa_warn = urwid.Text(wpa_warn_t)
221 225
222 self.backend_cat = urwid.Text(backend_cat_t)226 self.backend_cat = urwid.Text(backend_cat_t)
223 self.backend_cbox = ComboBox(backend_t)227 self.backend_ddown = DropDown()
228 backend_txt = urwid.Text(backend_t)
229 self.backend_cols = urwid.Columns([('fixed',backend_txt.pack()[0],backend_txt),urwid.AttrWrap(self.backend_ddown,'body','focus')])
224 230
225 self.debug_cat = urwid.Text(debug_cat_t)231 self.debug_cat = urwid.Text(debug_cat_t)
226 self.debug_mode_checkb = urwid.CheckBox(debug_mode_t)232 self.debug_mode_checkb = urwid.CheckBox(debug_mode_t)
@@ -230,9 +236,9 @@
230236
231237
232 advancedLB = urwid.ListBox([self.wpa_cat,238 advancedLB = urwid.ListBox([self.wpa_cat,
233 self.wpa_cbox,self.wpa_warn,_blank,239 self.wpa_cols,self.wpa_warn,_blank,
234 self.backend_cat,240 self.backend_cat,
235 self.backend_cbox,_blank,241 self.backend_cols,_blank,
236 self.debug_cat,242 self.debug_cat,
237 self.debug_mode_checkb, _blank,243 self.debug_mode_checkb, _blank,
238 self.wless_cat,244 self.wless_cat,
@@ -298,23 +304,24 @@
298 self.wpadrivers.append("ralink_legacy")304 self.wpadrivers.append("ralink_legacy")
299 # Same as above with the dbus.String305 # Same as above with the dbus.String
300 self.thedrivers = [unicode(w) for w in self.wpadrivers]306 self.thedrivers = [unicode(w) for w in self.wpadrivers]
301 self.wpa_cbox.set_list(self.thedrivers)307 self.wpa_ddown.set_list(self.thedrivers)
302 308
303 # Pick where to begin first:309 # Pick where to begin first:
304 def_driver = daemon.GetWPADriver()310 def_driver = daemon.GetWPADriver()
305 try:311 try:
306 self.wpa_cbox.set_focus(self.wpadrivers.index(def_driver))312 self.wpa_ddown.set_focus(self.wpadrivers.index(def_driver))
307 except ValueError:313 except ValueError:
308 pass # It defaults to 0 anyway (I hope)314 self.wpa_ddown.set_focus(0)
315 #self.wpa_cols._invalidate()
309316
310 self.backends = daemon.GetBackendList()317 self.backends = daemon.GetBackendList()
311 self.thebackends= [unicode(w) for w in self.backends]318 self.thebackends= [unicode(w) for w in self.backends]
312 self.backend_cbox.set_list(self.thebackends) 319 self.backend_ddown.set_list(self.thebackends)
313 cur_backend = daemon.GetSavedBackend()320 cur_backend = daemon.GetSavedBackend()
314 try:321 try:
315 self.backend_cbox.set_focus(self.thebackends.index(cur_backend))322 self.backend_ddown.set_focus(self.thebackends.index(cur_backend))
316 except ValueError:323 except ValueError:
317 self.backend_cbox.set_focus(0)324 self.backend_ddown.set_focus(0)
318325
319 # Two last checkboxes326 # Two last checkboxes
320 self.debug_mode_checkb.set_state(daemon.GetDebugMode())327 self.debug_mode_checkb.set_state(daemon.GetDebugMode())
@@ -334,7 +341,7 @@
334 self.search_dom.get_edit_text())341 self.search_dom.get_edit_text())
335 daemon.SetWirelessInterface(self.wless_edit.get_edit_text())342 daemon.SetWirelessInterface(self.wless_edit.get_edit_text())
336 daemon.SetWiredInterface(self.wired_edit.get_edit_text())343 daemon.SetWiredInterface(self.wired_edit.get_edit_text())
337 daemon.SetWPADriver(self.wpadrivers[self.wpa_cbox.get_focus()[1]])344 daemon.SetWPADriver(self.wpadrivers[self.wpa_ddown.get_focus()[1]])
338 daemon.SetAlwaysShowWiredInterface(self.always_show_wired_checkb.get_state())345 daemon.SetAlwaysShowWiredInterface(self.always_show_wired_checkb.get_state())
339 daemon.SetAutoReconnect(self.auto_reconn_checkb.get_state())346 daemon.SetAutoReconnect(self.auto_reconn_checkb.get_state())
340 daemon.SetDebugMode(self.debug_mode_checkb.get_state())347 daemon.SetDebugMode(self.debug_mode_checkb.get_state())
@@ -347,7 +354,7 @@
347 else:354 else:
348 daemon.SetWiredAutoConnectMethod(1)355 daemon.SetWiredAutoConnectMethod(1)
349356
350 daemon.SetBackend(self.backends[self.backend_cbox.get_focus()[1]])357 daemon.SetBackend(self.backends[self.backend_ddown.get_focus()[1]])
351 358
352 # External Programs Tab359 # External Programs Tab
353 if self.dhcp0.get_state():360 if self.dhcp0.get_state():
@@ -382,7 +389,3 @@
382 def global_dns_trigger(self,check_box,new_state,user_data=None):389 def global_dns_trigger(self,check_box,new_state,user_data=None):
383 for w in self.dns1,self.dns2,self.dns3,self.dns_dom,self.search_dom:390 for w in self.dns1,self.dns2,self.dns3,self.dns_dom,self.search_dom:
384 w.set_sensitive(new_state)391 w.set_sensitive(new_state)
385
386 def ready_widgets(self,ui,body):
387 self.wpa_cbox.build_combobox(body,ui,4)
388 self.backend_cbox.build_combobox(body,ui,8)
389392
=== modified file 'curses/wicd-curses.py'
--- curses/wicd-curses.py 2009-09-29 16:38:11 +0000
+++ curses/wicd-curses.py 2009-11-21 05:36:12 +0000
@@ -59,6 +59,7 @@
59from curses_misc import *59from curses_misc import *
60from prefs_curses import PrefsDialog60from prefs_curses import PrefsDialog
61import netentry_curses61import netentry_curses
62from popup import DropDown, PopUpTarget
6263
63from netentry_curses import WirelessSettingsDialog, WiredSettingsDialog,AdvancedSettingsDialog64from netentry_curses import WirelessSettingsDialog, WiredSettingsDialog,AdvancedSettingsDialog
6465
@@ -78,47 +79,10 @@
78from wicd.translations import language79from wicd.translations import language
79for i in language.keys():80for i in language.keys():
80 language[i] = language[i].decode('utf8')81 language[i] = language[i].decode('utf8')
8182# Dummies
82########################################83def handle_exit(f):
83##### SUPPORT CLASSES84 return f
84########################################85loop = None
85# Yay for decorators!
86def wrap_exceptions(func):
87 def wrapper(*args, **kargs):
88 try:
89 return func(*args, **kargs)
90 except KeyboardInterrupt:
91 #gobject.source_remove(redraw_tag)
92 loop.quit()
93 ui.stop()
94 print >> sys.stderr, "\n"+language['terminated']
95 #raise
96 except DBusException:
97 #gobject.source_remove(redraw_tag)
98 loop.quit()
99 ui.stop()
100 print >> sys.stderr,"\n"+language['dbus_fail']
101 raise
102 except :
103 # Quit the loop
104 #if 'loop' in locals():
105 loop.quit()
106 # Zap the screen
107 ui.stop()
108 # Print out standard notification:
109 print >> sys.stderr, "\n" + language['exception']
110 # Flush the buffer so that the notification is always above the
111 # backtrace
112 sys.stdout.flush()
113 # Raise the exception
114 #sleep(2)
115 raise
116
117 wrapper.__name__ = func.__name__
118 wrapper.__module__ = func.__module__
119 wrapper.__dict__ = func.__dict__
120 wrapper.__doc__ = func.__doc__
121 return wrapper
12286
123########################################87########################################
124##### SUPPORT FUNCTIONS88##### SUPPORT FUNCTIONS
@@ -126,7 +90,7 @@
12690
127# Look familiar? These two functions are clones of functions found in wicd's91# Look familiar? These two functions are clones of functions found in wicd's
128# gui.py file, except that now set_status is a function passed to them.92# gui.py file, except that now set_status is a function passed to them.
129@wrap_exceptions93@handle_exit
130def check_for_wired(wired_ip,set_status):94def check_for_wired(wired_ip,set_status):
131 """ Determine if wired is active, and if yes, set the status. """95 """ Determine if wired is active, and if yes, set the status. """
132 if wired_ip and wired.CheckPluggedIn():96 if wired_ip and wired.CheckPluggedIn():
@@ -135,7 +99,7 @@
135 else:99 else:
136 return False100 return False
137101
138@wrap_exceptions102@handle_exit
139def check_for_wireless(iwconfig, wireless_ip, set_status):103def check_for_wireless(iwconfig, wireless_ip, set_status):
140 """ Determine if wireless is active, and if yes, set the status. """104 """ Determine if wireless is active, and if yes, set the status. """
141 if not wireless_ip:105 if not wireless_ip:
@@ -485,9 +449,9 @@
485 self.key_edit.set_sensitive(new_state)449 self.key_edit.set_sensitive(new_state)
486450
487 def unhandled_key(self, size, k):451 def unhandled_key(self, size, k):
488 if k in ('up','page up'):452 if k in ('up', 'page up'):
489 self.frame.set_focus('body')453 self.frame.set_focus('body')
490 if k in ('down','page down'):454 if k in ('down', 'page down'):
491 self.frame.set_focus('footer')455 self.frame.set_focus('footer')
492 if k == 'enter':456 if k == 'enter':
493 # pass enter to the "ok" button457 # pass enter to the "ok" button
@@ -508,15 +472,14 @@
508##### APPLICATION INTERFACE CLASS472##### APPLICATION INTERFACE CLASS
509########################################473########################################
510# The Whole Shebang474# The Whole Shebang
511class appGUI():475class appGUI(urwid.WidgetWrap):
512 """The UI itself, all glory belongs to it!"""476 """The UI itself, all glory belongs to it!"""
513 def __init__(self):477 def __init__(self):
514 global loop478 global loop
515 self.size = ui.get_cols_rows()
516 # Happy screen saying that you can't do anything because we're scanning479 # Happy screen saying that you can't do anything because we're scanning
517 # for networks. :-)480 # for networks. :-)
518 self.screen_locker = urwid.Filler(urwid.Text(('important',language['scanning_stand_by']), align='center'))481 self.screen_locker = urwid.Filler(urwid.Text(('important', language['scanning_stand_by']), align='center'))
519 self.no_wlan = urwid.Filler(urwid.Text(('important',language['no_wireless_networks_found']), align='center'))482 self.no_wlan = urwid.Filler(urwid.Text(('important', language['no_wireless_networks_found']), align='center'))
520 self.TITLE = language['wicd_curses']483 self.TITLE = language['wicd_curses']
521 self.WIRED_IDX = 1484 self.WIRED_IDX = 1
522 self.WLESS_IDX = 3485 self.WLESS_IDX = 3
@@ -544,16 +507,16 @@
544 507
545 # Keymappings proposed by nanotube in #wicd508 # Keymappings proposed by nanotube in #wicd
546 keys = [509 keys = [
547 ('H' ,'Help' ,None),
548 ('right','Config',None),
549 #(' ',' ',None),510 #(' ',' ',None),
550 ('C' ,'Connect',None),511 ('H' ,'Help' , None),
551 ('D' ,'Disconn',None),512 ('right','Config', None),
552 ('R' ,'Refresh',None),513 ('C', 'Connect', None),
553 ('P' ,'Prefs',None),514 ('D', 'Disconn', None),
554 ('I' ,'Hidden',None),515 ('R', 'Refresh', None),
555 ('A' ,'About',None),516 ('P', 'Prefs', None),
556 ('Q' ,'Quit',loop.quit)517 ('I', 'Hidden', None),
518 ('A', 'About', None),
519 ('Q', 'Quit', None)
557 ]520 ]
558521
559 self.primaryCols = OptCols(keys,self.handle_keys)522 self.primaryCols = OptCols(keys,self.handle_keys)
@@ -572,11 +535,13 @@
572 self.init_other_optcols()535 self.init_other_optcols()
573536
574 self.frame.set_body(self.thePile)537 self.frame.set_body(self.thePile)
538 self.target = PopUpTarget(self.frame)
539 urwid.WidgetWrap.__init__(self,self.target)
575 # Booleans gallore!540 # Booleans gallore!
576 self.prev_state = False541 self.prev_state = False
577 self.connecting = False542 self.connecting = False
578 self.screen_locked = False543 self.screen_locked = False
579 self.do_diag_lock = False #Whether the screen is locked beneath a dialog544 self.do_diag_lock = False # Whether the screen is locked beneath a dialog
580 self.diag_type = 'none' # The type of dialog that is up545 self.diag_type = 'none' # The type of dialog that is up
581 self.scanning = False546 self.scanning = False
582547
@@ -584,19 +549,17 @@
584549
585 self.update_status()550 self.update_status()
586551
587 #self.max_wait = ui.max_wait
588
589 def doScan(self, sync=False):552 def doScan(self, sync=False):
590 self.scanning = True553 self.scanning = True
591 wireless.Scan(False)554 wireless.Scan(False)
592555
593 def init_other_optcols(self):556 def init_other_optcols(self):
594 # The "tabbed" preferences dialog557 # The "tabbed" preferences dialog
595 self.prefCols = OptCols( [ ('f10','OK'),558 self.prefCols = OptCols( [ ('f10','OK'),
596 ('page up','Tab Left',),559 ('page up','Tab Left',),
597 ('page down', 'Tab Right'),560 ('page down', 'Tab Right'),
598 ('esc','Cancel') ], self.handle_keys)561 ('esc','Cancel') ], self.handle_keys)
599 self.confCols = OptCols( [ ('f10','OK'),562 self.confCols = OptCols( [ ('f10','OK'),
600 ('esc','Cancel') ],self.handle_keys)563 ('esc','Cancel') ],self.handle_keys)
601564
602 # Does what it says it does565 # Does what it says it does
@@ -619,8 +582,9 @@
619 self.update_ui()582 self.update_ui()
620583
621 def raise_hidden_network_dialog(self):584 def raise_hidden_network_dialog(self):
622 dialog = InputDialog(('header',language["select_hidden_essid"]),7,30,language['scan'])585 dialog = InputDialog(
623 exitcode,hidden = dialog.run(ui,self.frame)586 ('header', language["select_hidden_essid"]), 7, 30, language['scan'])
587 exitcode,hidden = dialog.run(ui, self.frame)
624 if exitcode != -1:588 if exitcode != -1:
625 # That dialog will sit there for a while if I don't get rid of it589 # That dialog will sit there for a while if I don't get rid of it
626 self.update_ui()590 self.update_ui()
@@ -641,13 +605,11 @@
641 where = None605 where = None
642 else: 606 else:
643 where = self.thePile.get_focus().get_focus()[1]607 where = self.thePile.get_focus().get_focus()[1]
644 #where = self.wlessLB.get_focus()[1]
645 self.focusloc = [wlessorwired,where]608 self.focusloc = [wlessorwired,where]
646 609
647 # Be clunky until I get to a later stage of development.
648 # Update the list of networks. Usually called by DBus.610 # Update the list of networks. Usually called by DBus.
649 @wrap_exceptions611 @handle_exit
650 def update_netlist(self,state=None, x=None, force_check=False,firstrun=False):612 def update_netlist(self, state=None, x=None, force_check=False, firstrun=False):
651 # Don't even try to do this if we are running a dialog613 # Don't even try to do this if we are running a dialog
652 if self.diag:614 if self.diag:
653 return615 return
@@ -663,7 +625,7 @@
663 wiredL,wlessL = gen_network_list()625 wiredL,wlessL = gen_network_list()
664626
665 self.wiredCB.get_body().set_list(wiredL)627 self.wiredCB.get_body().set_list(wiredL)
666 self.wiredCB.get_body().build_combobox(self.frame,ui,3)628 self.wiredCB.get_body().build_combobox(self.frame, ui, 3)
667 if len(wlessL) != 0:629 if len(wlessL) != 0:
668 if self.wlessLB == self.no_wlan:630 if self.wlessLB == self.no_wlan:
669 self.wlessLB = urwid.ListBox(wlessL)631 self.wlessLB = urwid.ListBox(wlessL)
@@ -688,7 +650,7 @@
688 else:650 else:
689 self.thePile.set_focus(self.wiredCB)651 self.thePile.set_focus(self.wiredCB)
690 else:652 else:
691 self.thePile = urwid.Pile([('fixed',2,self.wlessH),self.wlessLB] )653 self.thePile = urwid.Pile([('fixed',2,self.wlessH), self.wlessLB] )
692 if not firstrun:654 if not firstrun:
693 self.frame.body = self.thePile655 self.frame.body = self.thePile
694 if self.focusloc[1] == None:656 if self.focusloc[1] == None:
@@ -705,7 +667,7 @@
705667
706 # Update the footer/status bar668 # Update the footer/status bar
707 conn_status = False669 conn_status = False
708 @wrap_exceptions670 @handle_exit
709 def update_status(self):671 def update_status(self):
710 wired_connecting = wired.CheckIfWiredConnecting()672 wired_connecting = wired.CheckIfWiredConnecting()
711 wireless_connecting = wireless.CheckIfWirelessConnecting()673 wireless_connecting = wireless.CheckIfWirelessConnecting()
@@ -715,10 +677,10 @@
715 if self.connecting: 677 if self.connecting:
716 if not self.conn_status:678 if not self.conn_status:
717 self.conn_status = True679 self.conn_status = True
718 gobject.timeout_add(250,self.set_connecting_status,fast)680 gobject.timeout_add(250, self.set_connecting_status, fast)
719 return True681 return True
720 else:682 else:
721 if check_for_wired(wired.GetWiredIP(''),self.set_status):683 if check_for_wired(wired.GetWiredIP(''), self.set_status):
722 return True684 return True
723 if not fast:685 if not fast:
724 iwconfig = wireless.GetIwconfig()686 iwconfig = wireless.GetIwconfig()
@@ -777,20 +739,17 @@
777 self.tcount+=1739 self.tcount+=1
778 toAppend=self.twirl[self.tcount % 4]740 toAppend=self.twirl[self.tcount % 4]
779 self.status_label.set_text(text+' '+toAppend)741 self.status_label.set_text(text+' '+toAppend)
780 self.update_ui()742 if loop is not None:
743 self.update_ui()
781 return True744 return True
782745
783 # Make sure the screen is still working by providing a pretty counter.746 #@handle_exit
784 # Not necessary in the end, but I will be using footer1 for stuff in747 def update_time(self,loop,data):
785 # the long run, so I might as well put something there.
786 #@wrap_exceptions
787 def update_time(self):
788 self.time_label.set_text(strftime('%H:%M:%S'))748 self.time_label.set_text(strftime('%H:%M:%S'))
789 self.update_ui()749 loop.set_alarm_in(0.5, self.update_time)
790 return True750 return True
791751
792 # Yeah, I'm copying code. Anything wrong with that?752 #@handle_exit
793 #@wrap_exceptions
794 def dbus_scan_finished(self):753 def dbus_scan_finished(self):
795 # I'm pretty sure that I'll need this later.754 # I'm pretty sure that I'll need this later.
796 #if not self.connecting:755 #if not self.connecting:
@@ -798,8 +757,7 @@
798 self.unlock_screen()757 self.unlock_screen()
799 self.scanning = False758 self.scanning = False
800759
801 # Same, same, same, same, same, same760 #@handle_exit
802 #@wrap_exceptions
803 def dbus_scan_started(self):761 def dbus_scan_started(self):
804 self.scanning = True762 self.scanning = True
805 if self.diag_type == 'conf':763 if self.diag_type == 'conf':
@@ -817,11 +775,14 @@
817 self.frame.set_footer(urwid.Pile([self.primaryCols,self.footer2]))775 self.frame.set_footer(urwid.Pile([self.primaryCols,self.footer2]))
818 self.update_ui()776 self.update_ui()
819777
820 def handle_keys(self,keys):778 def keypress(self,size,key):
779 self.handle_keys([key],size)
780 return key
781 def handle_keys(self,keys,size=None):
821 if not self.diag:782 if not self.diag:
822 # Handle keystrokes783 # Handle keystrokes
823 if "f8" in keys or 'Q' in keys or 'q' in keys:784 if "f8" in keys or 'Q' in keys or 'q' in keys:
824 loop.quit()785 raise urwid.ExitMainLoop()
825 #return False786 #return False
826 if "f5" in keys or 'R' in keys:787 if "f5" in keys or 'R' in keys:
827 self.lock_screen()788 self.lock_screen()
@@ -849,12 +810,12 @@
849 focus = self.frame.body.get_focus()810 focus = self.frame.body.get_focus()
850 if focus == self.wiredCB:811 if focus == self.wiredCB:
851 self.special = focus812 self.special = focus
852 self.connect("wired",0)813 self.connect("wired", 0)
853 else:814 else:
854 # wless list only other option, if it is around815 # wless list only other option, if it is around
855 if self.wlessLB != self.no_wlan:816 if self.wlessLB != self.no_wlan:
856 wid,pos = self.thePile.get_focus().get_focus()817 wid,pos = self.thePile.get_focus().get_focus()
857 self.connect("wireless",pos)818 self.connect("wireless", pos)
858 if "esc" in keys:819 if "esc" in keys:
859 # Force disconnect here if connection in progress820 # Force disconnect here if connection in progress
860 if self.connecting:821 if self.connecting:
@@ -863,11 +824,10 @@
863 daemon.SetForcedDisconnect(True)824 daemon.SetForcedDisconnect(True)
864 if "P" in keys:825 if "P" in keys:
865 if not self.pref:826 if not self.pref:
866 self.pref = PrefsDialog(self.frame,(0,1),ui,827 self.pref = PrefsDialog(self.frame, (0,1), ui,
867 dbusmanager.get_dbus_ifaces()) 828 dbusmanager.get_dbus_ifaces())
868 self.pref.load_settings()829 self.pref.load_settings()
869 self.pref.ready_widgets(ui,self.frame)830 self.frame.set_footer(urwid.Pile([self.prefCols, self.footer2]))
870 self.frame.set_footer(urwid.Pile([self.prefCols,self.footer2]))
871 self.diag = self.pref831 self.diag = self.pref
872 self.diag_type = 'pref'832 self.diag_type = 'pref'
873 self.frame.set_body(self.diag)833 self.frame.set_body(self.diag)
@@ -890,9 +850,9 @@
890 else:850 else:
891 nettype = 'wireless'851 nettype = 'wireless'
892 netname = str(self.wlessLB.get_focus()[1])852 netname = str(self.wlessLB.get_focus()[1])
893 run_configscript(self.frame,netname,nettype)853 run_configscript(self.frame, netname, nettype)
894 if "O" in keys:854 if "O" in keys:
895 exitcode,data = AdHocDialog().run(ui,self.frame)855 exitcode,data = AdHocDialog().run(ui, self.frame)
896 #data = (essid,ip,channel,use_ics,use_encrypt,key_edit)856 #data = (essid,ip,channel,use_ics,use_encrypt,key_edit)
897 if exitcode == 1:857 if exitcode == 1:
898 wireless.CreateAdHocNetwork(data[0],858 wireless.CreateAdHocNetwork(data[0],
@@ -901,53 +861,36 @@
901 data[5],861 data[5],
902 data[4], False)862 data[4], False)
903 863
904 for k in keys:864 if size is not None:
905 if urwid.is_mouse_event(k):865 for k in keys:
906 event, button, col, row = k866 if urwid.is_mouse_event(k):
907 self.frame.mouse_event( self.size,867 event, button, col, row = k
908 event, button, col, row,868 self.frame.mouse_event(size,
909 focus=True)869 event, button, col, row,
910 continue870 focus=True)
911 k = self.frame.keypress(self.size,k)871 continue
912 if self.diag:872 k = self.target.keypress(size, k)
913 if k == 'esc' or k == 'q' or k == 'Q':873 elif self.diag:
874 for k in keys:
875 # Hackish -> vvvvvvvvvvvvv
876 k = self.target.keypress(ui.get_cols_rows(), k)
877 if self.diag:
878 for k in keys:
879 if k == 'esc' or k == 'q' or k == 'Q':
914 self.restore_primary()880 self.restore_primary()
915 break881 break
916 if k == 'f10':882 if k == 'f10':
917 self.diag.save_settings()883 self.diag.save_settings()
918 self.restore_primary()884 self.restore_primary()
919 break885 break
920 if k == "window resize":
921 self.size = ui.get_cols_rows()
922 continue
923
924 def call_update_ui(self,source,cb_condition):
925 self.update_ui(True)
926 return True
927886
928 # Redraw the screen887 # Redraw the screen
929 @wrap_exceptions888 @handle_exit
930 def update_ui(self,from_key=False):889 def update_ui(self, from_key=True, from_alarm=False):
931 if not ui._started:890 global loop
932 return False891 if not loop:
933 canvas = self.frame.render( (self.size),True )892 loop._update()
934893 return True
935 # Update the screen
936 ui.draw_screen((self.size),canvas)
937 # Get the input data
938 input_data = ui.get_input_nonblocking()
939 max_wait = input_data[0]
940 keys = input_data[1]
941
942 # Resolve any "alarms" in the waiting
943 if self.update_tag != None:
944 gobject.source_remove(self.update_tag)
945 if from_key:
946 max_wait = 20
947 self.update_tag = gobject.timeout_add(max_wait, \
948 self.update_ui,True)
949 self.handle_keys(keys)
950 return False
951894
952 def connect(self, nettype, networkid, networkentry=None):895 def connect(self, nettype, networkid, networkentry=None):
953 """ Initiates the connection process in the daemon. """896 """ Initiates the connection process in the daemon. """
@@ -961,12 +904,8 @@
961 wired.ConnectWired()904 wired.ConnectWired()
962 self.update_status()905 self.update_status()
963906
964########################################
965##### INITIALIZATION FUNCTIONS
966########################################
967
968def main():907def main():
969 global ui, dlogger908 global ui, loop, dloggger, handle_exit, palette
970 # We are _not_ python.909 # We are _not_ python.
971 misc.RenameProcess('wicd-curses')910 misc.RenameProcess('wicd-curses')
972911
@@ -980,17 +919,11 @@
980 import urwid.curses_display919 import urwid.curses_display
981 ui = urwid.curses_display.Screen()920 ui = urwid.curses_display.Screen()
982921
983 #if options.debug:
984 # dlogger = logging.getLogger("Debug")
985 # dlogger.setLevel(logging.DEBUG)
986 # dlogger.debug("wicd-curses debug logging started")
987
988 # Default Color scheme.922 # Default Color scheme.
989 # Other potential color schemes can be found at:923 # Other potential color schemes can be found at:
990 # http://excess.org/urwid/wiki/RecommendedPalette924 # http://excess.org/urwid/wiki/RecommendedPalette
991
992 # Thanks to nanotube on #wicd for helping with this925 # Thanks to nanotube on #wicd for helping with this
993 ui.register_palette([926 palette = [
994 ('body','default','default'),927 ('body','default','default'),
995 ('focus','black','light gray'),928 ('focus','black','light gray'),
996 ('header','light blue','default'),929 ('header','light blue','default'),
@@ -1009,43 +942,45 @@
1009 ('green','dark green','default'),942 ('green','dark green','default'),
1010 ('blue','light blue','default'),943 ('blue','light blue','default'),
1011 ('red','dark red','default'),944 ('red','dark red','default'),
1012 ('bold','white','black','bold')])945 ('bold','white','black','bold')]
1013 # This is a wrapper around a function that calls another a function that946
1014 # is a wrapper around a infinite loop. Fun.
1015 urwid.set_encoding('utf8')947 urwid.set_encoding('utf8')
1016 ui.run_wrapper(run)948 try:
1017949 ui.run_wrapper(run)
1018@wrap_exceptions950 except KeyboardInterrupt:
951 #gobject.source_remove(redraw_tag)
952 ui.stop()
953 print >> sys.stderr, language['terminated']
954 except DBusException:
955 #gobject.source_remove(redraw_tag)
956 ui.stop()
957 print >> sys.stderr, language['dbus_fail']+"\n"
958 raise
959 except :
960 print >> sys.stderr, language['exception']+"\n"
961 sys.stdout.flush()
962 raise
1019def run():963def run():
1020 global loop964 global ui, loop, dloggger, handle_exit, palette
1021 loop = gobject.MainLoop()
1022
1023 ui.set_mouse_tracking()
1024 app = appGUI()965 app = appGUI()
1025966 loop = urwid.MainLoop(app, palette, ui,
1026967 event_loop=urwid.GLibEventLoop())
1027 # Connect signals and whatnot to UI screen control functions968
1028 bus.add_signal_receiver(app.dbus_scan_finished, 'SendEndScanSignal',969 bus.add_signal_receiver(app.dbus_scan_finished, 'SendEndScanSignal',
1029 'org.wicd.daemon.wireless')970 'org.wicd.daemon.wireless')
1030 bus.add_signal_receiver(app.dbus_scan_started, 'SendStartScanSignal',971 bus.add_signal_receiver(app.dbus_scan_started, 'SendStartScanSignal',
1031 'org.wicd.daemon.wireless')972 'org.wicd.daemon.wireless')
1032 # I've left this commented out many times.
1033 bus.add_signal_receiver(app.update_netlist, 'StatusChanged',973 bus.add_signal_receiver(app.update_netlist, 'StatusChanged',
1034 'org.wicd.daemon')974 'org.wicd.daemon')
1035 # Update what the interface looks like as an idle function975 #loop.add
1036 #gobject.idle_add(app.update_ui)
1037 # Update the connection status on the bottom every 1.5 s.
1038 gobject.timeout_add(2000,app.update_status)976 gobject.timeout_add(2000,app.update_status)
1039 # This will make sure that it is updated on the second.977 # This will make sure that it is updated on the second.
1040 gobject.timeout_add(500,app.update_time)978 loop.set_alarm_in(0.5,app.update_time)
1041979 handle_exit = loop.event_loop.handle_exit
1042 app.update_ui()
1043 # Get input file descriptors and add callbacks to the ui-updating function
1044 fds = ui.get_input_descriptors()
1045 for fd in fds:
1046 gobject.io_add_watch(fd, gobject.IO_IN,app.call_update_ui)
1047 loop.run()980 loop.run()
1048981
982
983
1049# Mostly borrowed from gui.py984# Mostly borrowed from gui.py
1050def setup_dbus(force=True):985def setup_dbus(force=True):
1051 global bus, daemon, wireless, wired, DBUS_AVAIL986 global bus, daemon, wireless, wired, DBUS_AVAIL
@@ -1082,14 +1017,11 @@
1082 sys.exit(1)1017 sys.exit(1)
1083 else:1018 else:
1084 raise1019 raise
1085 parser.set_defaults(screen='raw',debug=False)1020 parser.set_defaults(screen='raw', debug=False)
1086 parser.add_option("-r", "--raw-screen",action="store_const",const='raw'1021 parser.add_option("-r", "--raw-screen", action="store_const", const='raw'
1087 ,dest='screen',help="use urwid's raw screen controller (default)")1022 ,dest='screen', help="use urwid's raw screen controller (default)")
1088 parser.add_option("-c", "--curses-screen",action="store_const",const='curses',dest='screen',help="use urwid's curses screen controller")1023 parser.add_option("-c", "--curses-screen", action="store_const",const='curses',dest='screen', help="use urwid's curses screen controller")
1089 parser.add_option("-d", "--debug",action="store_true"1024 #parser.add_option("-d", "--debug",action="store_true"
1090 ,dest='debug',help="enable logging of wicd-curses (currently does nothing)")1025 # ,dest='debug',help="enable logging of wicd-curses (currently does nothing)")
1091 (options,args) = parser.parse_args()1026 (options,args) = parser.parse_args()
1092 main()1027 main()
1093 # Make sure that the terminal does not try to overwrite the last line of
1094 # the program, so that everything looks pretty.
1095 #print ""
10961028
=== modified file 'setup.py'
--- setup.py 2009-07-28 02:09:18 +0000
+++ setup.py 2009-11-21 05:36:12 +0000
@@ -502,6 +502,7 @@
502 data.append((wpath.lib, ['curses/wicd-curses.py']))502 data.append((wpath.lib, ['curses/wicd-curses.py']))
503 data.append((wpath.lib, ['curses/netentry_curses.py']))503 data.append((wpath.lib, ['curses/netentry_curses.py']))
504 data.append((wpath.lib, ['curses/configscript_curses.py']))504 data.append((wpath.lib, ['curses/configscript_curses.py']))
505 data.append((wpath.lib, ['curses/popup.py']))
505 data.append((wpath.bin, ['scripts/wicd-curses'])) 506 data.append((wpath.bin, ['scripts/wicd-curses']))
506 if not wpath.no_install_man:507 if not wpath.no_install_man:
507 data.append(( wpath.mandir + 'man8/', ['man/wicd-curses.8'])) 508 data.append(( wpath.mandir + 'man8/', ['man/wicd-curses.8']))

Subscribers

People subscribed via source and target branches

to status/vote changes: