mirror of
https://github.com/gryf/wicd.git
synced 2025-12-19 20:38:00 +01:00
Ad-hoc network support is added ("O").
This commit is should be the last one containing new interface elements. :-D
This also may not work directly from the install. I need to change some stuff
first.
curses/curses_misc.py:
Fixed bug in Dialog2 where mouse clicks would cause the program to crash
Added DynEdit and DynIntEdit, Simple DynWrapped widgets, nothing special
about them
curses/wicd-curses.py:
Added support for Ad-Hoc network controls (I don't know exactly how this
works)
curses/README,TODO,in/man=wicd-curses.8.in:
Ad-Hoc network support has been added
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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] )
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ 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
|
||||||
@@ -445,6 +445,66 @@ class WiredComboBox(ComboBox):
|
|||||||
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
|
||||||
########################################
|
########################################
|
||||||
@@ -784,6 +844,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)
|
||||||
|
#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):
|
||||||
|
|||||||
@@ -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-r251"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B wicd-curses
|
.B wicd-curses
|
||||||
\- curses-based wicd(8) controller
|
\- curses-based wicd(8) controller
|
||||||
@@ -57,6 +57,9 @@ 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.
|
||||||
|
|||||||
Reference in New Issue
Block a user