mirror of
https://github.com/gryf/wicd.git
synced 2025-12-24 07:02:29 +01:00
Merged curses changes.
This commit is contained in:
@@ -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='',
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
@@ -425,12 +409,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
|
||||
|
||||
@@ -93,9 +93,7 @@ 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
|
||||
@@ -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
|
||||
|
||||
@@ -704,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
|
||||
@@ -726,10 +724,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
|
||||
@@ -761,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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user