1
0
mirror of https://github.com/gryf/wicd.git synced 2026-01-04 12:54:12 +01:00

Merged latest changes from NaCl's branch.

This commit is contained in:
Robby Workman
2009-01-24 11:27:41 -06:00
7 changed files with 126 additions and 38 deletions

View File

@@ -29,6 +29,7 @@ H : Raise help dialog
S : Provide instructions for configuring scripts S : Provide instructions for configuring scripts
delete : Delete selected wired network profile (from the wired ComboBox) delete : Delete selected wired network profile (from the wired ComboBox)
F2 : Rename selected wired network profile (from the wired ComboBox) F2 : Rename selected wired network profile (from the wired ComboBox)
O : Raise ad-hoc network dialog
IN DIALOGS (Meta usually is "Alt"): IN DIALOGS (Meta usually is "Alt"):
ESC or Q: Quit dialog without saving information (if present) ESC or Q: Quit dialog without saving information (if present)

View File

@@ -3,5 +3,4 @@ Things to do (in no particular order):
* Implement a keyhandler function for the overall frame * Implement a keyhandler function for the overall frame
* Make keystrokes customizable * Make keystrokes customizable
* Make color schemes customizable * Make color schemes customizable
* Implement a "make an ad-hoc network" dialog
* Perform a mass code cleanup * Perform a mass code cleanup

View File

@@ -88,6 +88,20 @@ class DynWrap(urwid.AttrWrap):
def selectable(self): def selectable(self):
return self._sensitive return self._sensitive
# Just an Edit Dynwrapped to the most common specifications
class DynEdit(DynWrap):
def __init__(self,caption='',edit_text='',sensitive=True,attrs=('editbx','editnfc'),focus_attr='editfc'):
caption = ('editcp',caption + ': ')
edit = urwid.Edit(caption,edit_text)
self.__super.__init__(edit,sensitive,attrs,focus_attr)
# Just an IntEdit Dynwrapped to the most common specifications
class DynIntEdit(DynWrap):
def __init__(self,caption='',edit_text='',sensitive=True,attrs=('editbx','editnfc'),focus_attr='editfc'):
caption = ('editcp',caption + ':')
edit = urwid.IntEdit(caption,edit_text)
self.__super.__init__(edit,sensitive,attrs,focus_attr)
class MaskingEditException(Exception): class MaskingEditException(Exception):
pass pass
@@ -436,13 +450,14 @@ class Dialog2(urwid.WidgetWrap):
overlay.mouse_event( size, overlay.mouse_event( size,
event, button, col, row, event, button, col, row,
focus=True) focus=True)
if k == 'window resize': else:
size = ui.get_cols_rows() if k == 'window resize':
k = self.view.keypress( size, k ) size = ui.get_cols_rows()
if k == 'esc': k = self.view.keypress( size, k )
raise DialogExit(-1) if k == 'esc':
if k: raise DialogExit(-1)
self.unhandled_key( size, k) if k:
self.unhandled_key( size, k)
except DialogExit, e: except DialogExit, e:
return self.on_exit( e.args[0] ) return self.on_exit( e.args[0] )

View File

@@ -34,8 +34,7 @@ at least get a network connection. Or those who don't like using X. ;-)
""" """
# UI stuff # UI stuff
#import urwid.raw_display # This library is the only reason why I wrote this program.
import urwid.curses_display
import urwid import urwid
# DBus communication stuff # DBus communication stuff
@@ -54,14 +53,19 @@ import sys
from time import sleep from time import sleep
# Curses UIs for other stuff # Curses UIs for other stuff
from curses_misc import SelText,ComboBox,TextDialog,InputDialog,error from curses_misc import SelText,DynEdit,DynIntEdit,ComboBox,Dialog2,TextDialog,InputDialog,error
from prefs_curses import PrefsDialog from prefs_curses import PrefsDialog
import netentry_curses import netentry_curses
from netentry_curses import WirelessSettingsDialog, WiredSettingsDialog from netentry_curses import WirelessSettingsDialog, WiredSettingsDialog
from optparse import OptionParser
# Stuff about getting the script configurer running # Stuff about getting the script configurer running
from grp import getgrgid #from grp import getgrgid
from os import getgroups,system #from os import getgroups,system
CURSES_REVNO=wpath.curses_revision
language = misc.get_language_list_gui() language = misc.get_language_list_gui()
@@ -245,7 +249,8 @@ def help_dialog(body):
('bold','F5')," or ", ('bold','R')," Refresh network list\n", ('bold','F5')," or ", ('bold','R')," Refresh network list\n",
('bold','P')," Prefrences dialog\n", ('bold','P')," Prefrences dialog\n",
('bold','I')," Scan for hidden networks\n", ('bold','I')," Scan for hidden networks\n",
('bold','S')," Select scripts\n" ('bold','S')," Select scripts\n",
('bold','O')," Set up Ad-hoc network\n"
] ]
help = TextDialog(theText,15,62,header=('header',"Wicd-Curses Help")) help = TextDialog(theText,15,62,header=('header',"Wicd-Curses Help"))
help.run(ui,body) help.run(ui,body)
@@ -335,15 +340,6 @@ class NetLabel(urwid.WidgetWrap):
return True return True
def keypress(self,size,key): def keypress(self,size,key):
return self._w.keypress(size,key) return self._w.keypress(size,key)
#if key == 'C':
# conf = NetEntryBase(dbusmanager.get_dbus_ifaces())
# conf.run(ui,ui.get_cols_rows(),)
#elif key == 'S':
# Configure scripts
# pass
#elif key == 'enter':
# self.connect()
#return key
def connect(self): def connect(self):
# This should work. # This should work.
wireless.ConnectWireless(self.id) wireless.ConnectWireless(self.id)
@@ -430,21 +426,72 @@ class WiredComboBox(ComboBox):
self.set_focus(self.theList.index(name)) self.set_focus(self.theList.index(name))
self.rebuild_combobox() self.rebuild_combobox()
return key return key
#if key == 'C':
# Configure the network
# pass
#elif key == 'S':
# Configure scripts
# pass
#elif key == 'enter':
# self.connect()
#return key
def get_selected_profile(self): def get_selected_profile(self):
"""Get the selected wired profile""" """Get the selected wired profile"""
loc = self.get_focus()[1] loc = self.get_focus()[1]
return self.theList[loc] return self.theList[loc]
# Dialog2 that initiates an Ad-Hoc network connection
class AdHocDialog(Dialog2):
def __init__(self):
essid_t = language['essid']
ip_t = language['ip']
channel_t = language['channel']
key_t = " " + language['key']
use_ics_t = language['use_ics']
use_encrypt_t = language['use_wep_encryption']
self.essid_edit = DynEdit(essid_t)
self.ip_edit = DynEdit(ip_t)
self.channel_edit = DynIntEdit(channel_t)
self.key_edit = DynEdit(key_t,sensitive=False)
self.use_ics_chkb = urwid.CheckBox(use_ics_t)
self.use_encrypt_chkb = urwid.CheckBox(use_encrypt_t,
on_state_change=self.encrypt_callback)
blank = urwid.Text('')
# Set defaults
self.essid_edit.set_edit_text("My_Adhoc_Network")
self.ip_edit.set_edit_text("169.254.12.10")
self.channel_edit.set_edit_text("3")
l = [self.essid_edit,self.ip_edit,self.channel_edit,blank,
self.use_ics_chkb,self.use_encrypt_chkb,self.key_edit]
#for line in text:
# l.append( urwid.Text( line,align=align))
body = urwid.ListBox(l)
#body = urwid.AttrWrap(body, 'body')
header = ('header',"Create an Ad-Hoc network")
Dialog2.__init__(self, header, 15, 50, body)
self.add_buttons([('OK',1),('Cancel',-1)])
self.frame.set_focus('body')
def encrypt_callback(self,chkbox,new_state,user_info=None):
self.key_edit.set_sensitive(new_state)
def unhandled_key(self, size, k):
if k in ('up','page up'):
self.frame.set_focus('body')
if k in ('down','page down'):
self.frame.set_focus('footer')
if k == 'enter':
# pass enter to the "ok" button
self.frame.set_focus('footer')
self.buttons.set_focus(0)
self.view.keypress( size, k )
def on_exit(self,exitcode):
data = ( self.essid_edit.get_edit_text(),
self.ip_edit.get_edit_text(),
self.channel_edit.get_edit_text(),
self.use_ics_chkb.get_state(),
self.use_encrypt_chkb.get_state(),
self.key_edit.get_edit_text())
return exitcode, data
######################################## ########################################
##### APPLICATION INTERFACE CLASS ##### APPLICATION INTERFACE CLASS
######################################## ########################################
@@ -533,7 +580,7 @@ class appGUI():
# That dialog will sit there for a while if I don't get rid of it # That dialog will sit there for a while if I don't get rid of it
self.update_ui() self.update_ui()
wireless.SetHiddenNetworkESSID(misc.noneToString(hidden)) wireless.SetHiddenNetworkESSID(misc.noneToString(hidden))
wireless.Scan() wireless.Scan(True)
wireless.SetHiddenNetworkESSID("") wireless.SetHiddenNetworkESSID("")
def update_focusloc(self): def update_focusloc(self):
@@ -728,7 +775,7 @@ class appGUI():
return False return False
if "f5" in keys or 'R' in keys: if "f5" in keys or 'R' in keys:
self.lock_screen() self.lock_screen()
wireless.Scan() wireless.Scan(True)
if "D" in keys: if "D" in keys:
# Disconnect from all networks. # Disconnect from all networks.
daemon.Disconnect() daemon.Disconnect()
@@ -784,6 +831,15 @@ class appGUI():
nettype = 'wireless' nettype = 'wireless'
netname = str(self.wiredLB.get_focus()[1]) netname = str(self.wiredLB.get_focus()[1])
run_configscript(self.frame,netname,nettype) run_configscript(self.frame,netname,nettype)
if "O" in keys:
exitcode,data = AdHocDialog().run(ui,self.frame)
#data = (essid,ip,channel,use_ics,use_encrypt,key_edit)
if exitcode == 1:
wireless.CreateAdHocNetwork(data[0],
data[2],
data[1], "WEP",
data[5],
data[4], False)
for k in keys: for k in keys:
if urwid.is_mouse_event(k): if urwid.is_mouse_event(k):
@@ -819,7 +875,15 @@ def main():
# We are _not_ python. # We are _not_ python.
misc.RenameProcess('wicd-curses') misc.RenameProcess('wicd-curses')
ui = urwid.curses_display.Screen() # Import the screen based on whatever the user picked.
# The raw_display will have some features that may be useful to users
# later
if options.rawscreen:
import urwid.raw_display
ui = urwid.raw_display.Screen()
else:
import urwid.curses_display
ui = urwid.curses_display.Screen()
# Default Color scheme. # Default Color scheme.
# Other potential color schemes can be found at: # Other potential color schemes can be found at:
# http://excess.org/urwid/wiki/RecommendedPalette # http://excess.org/urwid/wiki/RecommendedPalette
@@ -901,6 +965,10 @@ setup_dbus()
##### MAIN ENTRY POINT ##### MAIN ENTRY POINT
######################################## ########################################
if __name__ == '__main__': if __name__ == '__main__':
parser = OptionParser(version="wicd-curses-%s (using wicd %s)" % (CURSES_REVNO,daemon.Hello()))
parser.add_option("-r", "--raw-screen",action="store_true",dest='rawscreen',
help="use urwid's raw screen controller")
(options,args) = parser.parse_args()
main() main()
# Make sure that the terminal does not try to overwrite the last line of # Make sure that the terminal does not try to overwrite the last line of
# the program, so that everything looks pretty. # the program, so that everything looks pretty.

View File

@@ -1,5 +1,5 @@
.\" First revision was r203 .\" First revision was r203
.TH WICD-CURSES "8" "January 2009" "wicd-curses-r250" .TH WICD-CURSES "8" "January 2009" "wicd-curses-%CURSES_REVNO%"
.SH NAME .SH NAME
.B wicd-curses .B wicd-curses
\- curses-based wicd(8) controller \- curses-based wicd(8) controller
@@ -10,7 +10,6 @@ It is designed to imitate the GTK-based wicd-client(1) as much as possible, and
This man page only documents the current status of wicd-curses. This may/may not be the most up-to-date document. This man page only documents the current status of wicd-curses. This may/may not be the most up-to-date document.
.SH "ARGUMENTS" .SH "ARGUMENTS"
These are not implemented yet.
.TP .TP
.BR "\-r" , " \-\-raw\-screen" .BR "\-r" , " \-\-raw\-screen"
Use Urwid's raw console display, instead of the (faster) curses-based one. This may be useful if you are experiencing unicode problems. Use Urwid's raw console display, instead of the (faster) curses-based one. This may be useful if you are experiencing unicode problems.
@@ -57,8 +56,11 @@ Rename the selected wired network profile (from the wired network combo box at t
.BR S .BR S
.\"Bring up the script selector for the selected network (requires superuser privileges) .\"Bring up the script selector for the selected network (requires superuser privileges)
Bring up instructions on how to edit the scripts. I have implemented a way to do this in the interface itself, but making it function with all Linux distros would be difficult. Since you are reading this, you should know how to do what I suggest. ;-) Bring up instructions on how to edit the scripts. I have implemented a way to do this in the interface itself, but making it function with all Linux distros would be difficult. Since you are reading this, you should know how to do what I suggest. ;-)
.TP
.BR O
Raise the Ad-Hoc network creation dialog
".SH "FILES" .SH "FILES"
These are not used yet. These are not used yet.
.TP .TP
.I ~/.wicd/WHEREAREMYFILES .I ~/.wicd/WHEREAREMYFILES

View File

@@ -19,6 +19,7 @@ current = os.path.dirname(os.path.realpath(__file__)) + '/'
version = '%VERSION%' version = '%VERSION%'
revision = '%REVNO%' revision = '%REVNO%'
curses_revision = '%CURSES_REVNO%'
# DIRECTORIES # DIRECTORIES

View File

@@ -27,6 +27,7 @@ import subprocess
# VERSIONNUMBER # VERSIONNUMBER
VERSION_NUM = '1.6.0' VERSION_NUM = '1.6.0'
REVISION_NUM = 'unknown' REVISION_NUM = 'unknown'
CURSES_REVNO = 'r254'
try: try:
if not os.path.exists('vcsinfo.py'): if not os.path.exists('vcsinfo.py'):
@@ -268,6 +269,7 @@ class configure(Command):
# other things to replace that aren't arguments # other things to replace that aren't arguments
line = line.replace('%VERSION%', str(VERSION_NUM)) line = line.replace('%VERSION%', str(VERSION_NUM))
line = line.replace('%REVNO%', str(REVISION_NUM)) line = line.replace('%REVNO%', str(REVISION_NUM))
line = line.replace('%CURSES_REVNO%', str(CURSES_REVNO))
item_out.write(line) item_out.write(line)