[Spambayes-checkins] spambayes/Outlook2000/dialogs
opt_processors.py, 1.6, 1.7
Mark Hammond
mhammond at users.sourceforge.net
Thu Aug 21 07:13:49 EDT 2003
Update of /cvsroot/spambayes/spambayes/Outlook2000/dialogs
In directory sc8-pr-cvs1:/tmp/cvs-serv3542
Modified Files:
opt_processors.py
Log Message:
Restructure FolderID processors suitable for subclassing.
Index: opt_processors.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/opt_processors.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** opt_processors.py 19 Aug 2003 12:55:39 -0000 1.6
--- opt_processors.py 21 Aug 2003 13:13:47 -0000 1.7
***************
*** 46,49 ****
--- 46,56 ----
option.set(value)
self.NotifyOptionChanged(option)
+ def GetOptionValue(self, option = None):
+ if option is None:
+ option = self.option
+ ret = option.get()
+ print "Got option '%s' (%s) -> %s" % \
+ (option.display_name(), option.name, ret)
+ return ret
# Only sub-classes know how to update their controls from the value.
***************
*** 62,66 ****
self.UpdateValue_FromControl()
def UpdateControl_FromValue(self):
! value = self.option.get()
win32gui.SendMessage(self.GetControl(), win32con.BM_SETCHECK, value)
for other in self.other_ids:
--- 69,73 ----
self.UpdateValue_FromControl()
def UpdateControl_FromValue(self):
! value = self.GetOptionValue()
win32gui.SendMessage(self.GetControl(), win32con.BM_SETCHECK, value)
for other in self.other_ids:
***************
*** 77,81 ****
self.UpdateValue_FromControl()
def UpdateControl_FromValue(self):
! value = self.option.get()
i = 0
first = chwnd = self.GetControl()
--- 84,88 ----
self.UpdateValue_FromControl()
def UpdateControl_FromValue(self):
! value = self.GetOptionValue()
i = 0
first = chwnd = self.GetControl()
***************
*** 127,131 ****
combo = self.GetControl()
index = sel_index = 0
! value = self.option.get()
for opt,text in self.option_to_text:
win32gui.SendMessage(combo, win32con.CB_ADDSTRING, 0, text)
--- 134,138 ----
combo = self.GetControl()
index = sel_index = 0
! value = self.GetOptionValue()
for opt,text in self.option_to_text:
win32gui.SendMessage(combo, win32con.CB_ADDSTRING, 0, text)
***************
*** 191,195 ****
def UpdateControl_FromValue(self):
! win32gui.SendMessage(self.GetControl(), win32con.WM_SETTEXT, 0, str(self.option.get()))
self.UpdateSlider_FromEdit()
--- 198,203 ----
def UpdateControl_FromValue(self):
! win32gui.SendMessage(self.GetControl(), win32con.WM_SETTEXT, 0,
! str(self.GetOptionValue()))
self.UpdateSlider_FromEdit()
***************
*** 199,203 ****
# Get as float so we dont fail should the .0 be there, but
# then convert to int as the slider only works with ints
! val = int(float(self.option.get()))
except ValueError:
return
--- 207,211 ----
# Get as float so we dont fail should the .0 be there, but
# then convert to int as the slider only works with ints
! val = int(float(self.GetOptionValue()))
except ValueError:
return
***************
*** 217,222 ****
# Folder IDs, and the "include_sub" option, if applicable.
class FolderIDProcessor(OptionControlProcessor):
! def __init__(self, window, control_ids, option, option_include_sub = None):
self.button_id = control_ids[1]
if option_include_sub:
--- 225,234 ----
# Folder IDs, and the "include_sub" option, if applicable.
class FolderIDProcessor(OptionControlProcessor):
! def __init__(self, window, control_ids,
! option, option_include_sub = None,
! use_fqn = False, name_joiner = "; "):
self.button_id = control_ids[1]
+ self.use_fqn = use_fqn
+ self.name_joiner = name_joiner
if option_include_sub:
***************
*** 230,261 ****
OptionControlProcessor.__init__(self, window, control_ids, option)
! def OnCommand(self, wparam, lparam):
mgr = self.window.manager
! id = win32api.LOWORD(wparam)
! if id == self.button_id:
! is_multi = self.option.multiple_values_allowed()
if is_multi:
! ids = self.option.get()
else:
! ids = [self.option.get()]
! from dialogs import FolderSelector
if self.option_include_sub:
! cb_state = self.option_include_sub.get()
! else:
! cb_state = None # don't show it.
! d = FolderSelector.FolderSelector(self.window.hwnd,
! mgr,
! ids,
! single_select=not is_multi,
! checkbox_state=cb_state)
! if d.DoModal() == win32con.IDOK:
! ids, include_sub = d.GetSelectedIDs()
! if is_multi:
! self.SetOptionValue(ids)
! else:
! self.SetOptionValue(ids[0])
! if self.option_include_sub:
! self.SetOptionValue(include_sub, self.option_include_sub)
! self.UpdateControl_FromValue()
def GetPopupHelpText(self, idFrom):
--- 242,278 ----
OptionControlProcessor.__init__(self, window, control_ids, option)
! def DoBrowse(self):
mgr = self.window.manager
! is_multi = self.option.multiple_values_allowed()
! if is_multi:
! ids = self.GetOptionValue()
! else:
! ids = [self.GetOptionValue()]
! from dialogs import FolderSelector
! if self.option_include_sub:
! cb_state = self.option_include_sub.get()
! else:
! cb_state = None # don't show it.
! d = FolderSelector.FolderSelector(self.window.hwnd,
! mgr,
! ids,
! single_select=not is_multi,
! checkbox_state=cb_state)
! if d.DoModal() == win32con.IDOK:
! ids, include_sub = d.GetSelectedIDs()
if is_multi:
! self.SetOptionValue(ids)
else:
! self.SetOptionValue(ids[0])
if self.option_include_sub:
! self.SetOptionValue(include_sub, self.option_include_sub)
! self.UpdateControl_FromValue()
! return True
! return False
!
! def OnCommand(self, wparam, lparam):
! id = win32api.LOWORD(wparam)
! if id == self.button_id:
! self.DoBrowse()
def GetPopupHelpText(self, idFrom):
***************
*** 268,274 ****
mgr = self.window.manager
if self.option.multiple_values_allowed():
! ids = self.option.get()
else:
! ids = [self.option.get()]
names = []
for eid in ids:
--- 285,291 ----
mgr = self.window.manager
if self.option.multiple_values_allowed():
! ids = self.GetOptionValue()
else:
! ids = [self.GetOptionValue()]
names = []
for eid in ids:
***************
*** 278,284 ****
name = "<unknown folder>"
else:
! name = folder.name
names.append(name)
! win32gui.SetWindowText(self.GetControl(), "; ".join(names))
def UpdateValue_FromControl(self):
--- 295,304 ----
name = "<unknown folder>"
else:
! if self.use_fqn:
! name = folder.GetFQName()
! else:
! name = folder.name
names.append(name)
! win32gui.SetWindowText(self.GetControl(), self.name_joiner.join(names))
def UpdateValue_FromControl(self):
More information about the Spambayes-checkins
mailing list