[Spambayes-checkins] spambayes/Outlook2000/dialogs dialog_map.py, 1.2, 1.3

Adam Walker xenogeist at users.sourceforge.net
Sun Aug 17 15:19:07 EDT 2003


Update of /cvsroot/spambayes/spambayes/Outlook2000/dialogs
In directory sc8-pr-cvs1:/tmp/cvs-serv18534/Outlook2000/dialogs

Modified Files:
	dialog_map.py 
Log Message:
Dialog re-org. Added a sb logo and moved most dialogs into a tab control on the manager dialog. One thing left to do is supply a true cancel action, currently cancel and ok do the same thing.

Index: dialog_map.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/dialog_map.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** dialog_map.py	10 Aug 2003 07:26:49 -0000	1.2
--- dialog_map.py	17 Aug 2003 21:19:05 -0000	1.3
***************
*** 6,10 ****
  from opt_processors import *
  
! from dialogs import ShowDialog
  
  # "dialog specific" processors:
--- 6,10 ----
  from opt_processors import *
  
! from dialogs import ShowDialog, MakePropertyPage
  
  # "dialog specific" processors:
***************
*** 35,38 ****
--- 35,60 ----
                               0, db_status)
  
+ class IntProcessor(OptionControlProcessor):
+     def UpdateControl_FromValue(self):
+         win32gui.SendMessage(self.GetControl(), win32con.WM_SETTEXT, 0, str(self.option.get()))
+     def UpdateValue_FromControl(self):
+         buf_size = 100
+         buf = win32gui.PyMakeBuffer(buf_size)
+         nchars = win32gui.SendMessage(self.GetControl(), win32con.WM_GETTEXT,
+                                       buf_size, buf)
+         str_val = buf[:nchars]
+         val = int(str_val)
+         if val < 0 or val > 10:
+             raise ValueError, "Value must be between 0 and 10"
+         self.SetOptionValue(val)
+     def OnCommand(self, wparam, lparam):
+         code = win32api.HIWORD(wparam)
+         if code==win32con.EN_CHANGE:
+             try:
+                 self.UpdateValue_FromControl()
+             except ValueError:
+                 # They are typing - value may be currently invalid
+                 pass
+ 
  class FilterEnableProcessor(BoolButtonProcessor):
      def UpdateValue_FromControl(self):
***************
*** 45,48 ****
--- 67,116 ----
          check = not not check # force bool!
          self.SetOptionValue(check)
+ 
+ # This class will likely go away when the real options are made for
+ # delay timers
+ class MsSliderProcessor(EditNumberProcessor):
+     def __init__(self, window, control_ids, option):
+         EditNumberProcessor.__init__(self, window, control_ids, option)
+     def InitSlider(self):
+         slider = self.GetControl(self.slider_id)
+         win32gui.SendMessage(slider, commctrl.TBM_SETRANGE, 0, MAKELONG(0, 10))
+         win32gui.SendMessage(slider, commctrl.TBM_SETLINESIZE, 0, 1)
+         win32gui.SendMessage(slider, commctrl.TBM_SETPAGESIZE, 0, 1)
+         win32gui.SendMessage(slider, commctrl.TBM_SETTICFREQ, 1, 0)
+         self.UpdateSlider_FromEdit()
+     def OnMessage(self, msg, wparam, lparam):
+         slider = self.GetControl(self.slider_id)
+         if slider == lparam:
+             slider_pos = win32gui.SendMessage(slider, commctrl.TBM_GETPOS, 0, 0)
+             slider_pos = int(slider_pos)
+             str_val = str(slider_pos)
+             edit = self.GetControl()
+             win32gui.SendMessage(edit, win32con.WM_SETTEXT, 0, str_val)
+     def UpdateSlider_FromEdit(self):
+         slider = self.GetControl(self.slider_id)
+         try:
+             # 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()/1000))
+         except ValueError:
+             return
+         win32gui.SendMessage(slider, commctrl.TBM_SETPOS, 1, val)
+ 
+     def UpdateControl_FromValue(self):
+         value = self.option.get()/1000
+         win32gui.SendMessage(self.GetControl(), win32con.WM_SETTEXT, 0, str(value))
+         self.UpdateSlider_FromEdit()
+     def UpdateValue_FromControl(self):
+         buf_size = 100
+         buf = win32gui.PyMakeBuffer(buf_size)
+         nchars = win32gui.SendMessage(self.GetControl(), win32con.WM_GETTEXT,
+                                       buf_size, buf)
+         str_val = buf[:nchars]
+         val = int(str_val)
+         if val < 0 or val > 10:
+             raise ValueError, "Value must be between 0 and 10"
+         self.SetOptionValue(val*1000)
+ 
      
  class FilterStatusProcessor(ControlProcessor):
***************
*** 81,84 ****
--- 149,207 ----
          win32gui.SendMessage(self.GetControl(), win32con.WM_SETTEXT,
                               0, filter_status)
+ class TabProcessor(ControlProcessor):
+     def Init(self):
+         self.pages = {}
+         self.currentPage = None
+         self.currentPageIndex = -1
+         self.currentPageHwnd = None
+         self.addPage(0, "IDD_GENERAL", "General")
+         self.addPage(1, "IDD_FILTER_SPAM", "Spam")
+         self.addPage(2, "IDD_FILTER_UNSURE", "Possible Spam")
+         self.addPage(3, "IDD_FILTER_NOW", "Filter Now")
+         self.addPage(4, "IDD_TRAINING", "Training")
+         self.addPage(5, "IDD_ADVANCED", "Advanced")
+         self.switchToPage(0)
+     def OnNotify(self, nmhdr, wparam, lparam):
+         # this does not appear to be in commctrl module
+         selChangedCode =  5177342
+         code = nmhdr[2]
+         if code==selChangedCode:
+             index = win32gui.SendMessage(self.GetControl(), commctrl.TCM_GETCURSEL, 0,0)
+             if index!=self.currentPageIndex:
+                 self.switchToPage(index)
+ 
+     def switchToPage(self, index):
+         if self.currentPageHwnd is not None:
+             if not self.currentPage.SaveAllControls():
+                 win32gui.SendMessage(self.GetControl(), commctrl.TCM_SETCURSEL, self.currentPageIndex,0)
+                 return 1
+             win32gui.DestroyWindow(self.currentPageHwnd)
+         self.currentPage = MakePropertyPage(self.GetControl(), self.window.manager, self.pages[index])
+         self.currentPageHwnd = self.currentPage.CreateWindow()
+         self.currentPageIndex = index
+         return 0
+         
+     def addPage(self, item, idName, label):
+         format = "iiiiiii"
+         lbuf = win32gui.PyMakeBuffer(len(label)+1)
+         address,l = win32gui.PyGetBufferAddressAndLen(lbuf)
+         win32gui.PySetString(address, label)
+         
+         buf = struct.pack(format,
+             commctrl.TCIF_TEXT, # mask
+             0, # state
+             0, # state mask
+             address,
+             0, #unused
+             0, #image
+             item
+             )
+         item = win32gui.SendMessage(self.GetControl(),
+                              commctrl.TCM_INSERTITEM,
+                              item,
+                              buf)
+         self.pages[item] = idName
+         
+ 
  def ShowAbout(mgr):
      mgr.ShowHtml("about.html")
***************
*** 107,112 ****
--- 230,240 ----
  dialog_map = {
      "IDD_MANAGER" : (
+         (ImageProcessor,          "IDC_LOGO_GRAPHIC"),
          (CloseButtonProcessor,    "IDOK IDCANCEL"),
+         (TabProcessor,            "IDC_TAB"),
          (VersionStringProcessor,  "IDC_VERSION"),
+         (CommandButtonProcessor,  "IDC_ABOUT_BTN", ShowAbout, ()),
+     ),
+     "IDD_GENERAL": (
          (TrainingStatusProcessor, "IDC_TRAINING_STATUS"),
          (FilterEnableProcessor,   "IDC_BUT_FILTER_ENABLE", "Filter.enabled"),
***************
*** 119,126 ****
          (DialogCommand,           "IDC_BUT_FILTER_DEFINE", "IDD_FILTER"),
          (DialogCommand,           "IDC_BUT_TRAIN_NOW", "IDD_TRAINING"),
!         (CommandButtonProcessor,  "IDC_BUT_ABOUT", ShowAbout, ()),
!     ),
      "IDD_FILTER_NOW" : (
-         (CloseButtonProcessor,    "IDOK IDCANCEL"),
          (BoolButtonProcessor,     "IDC_BUT_UNREAD",    "Filter_Now.only_unread"),
          (BoolButtonProcessor,     "IDC_BUT_UNSEEN",    "Filter_Now.only_unseen"),
--- 247,254 ----
          (DialogCommand,           "IDC_BUT_FILTER_DEFINE", "IDD_FILTER"),
          (DialogCommand,           "IDC_BUT_TRAIN_NOW", "IDD_TRAINING"),
!         (DialogCommand,           "IDC_ADVANCED_BTN", "IDD_ADVANCED"),
!         (BoolButtonProcessor,     "IDC_SAVE_SPAM_SCORE",    "Filter.save_spam_info"),
!         ),
      "IDD_FILTER_NOW" : (
          (BoolButtonProcessor,     "IDC_BUT_UNREAD",    "Filter_Now.only_unread"),
          (BoolButtonProcessor,     "IDC_BUT_UNSEEN",    "Filter_Now.only_unseen"),
***************
*** 132,150 ****
          (AsyncCommandProcessor,   "IDC_START IDC_PROGRESS IDC_PROGRESS_TEXT",
                                    filter.filterer, "Start Filtering", "Stop Filtering",
!                                   "IDC_BUT_UNSEEN IDC_BUT_UNREAD IDC_BROWSE " \
!                                   "IDOK IDC_BUT_ACT_SCORE IDC_BUT_ACT_ALL"),
      ),
!     "IDD_FILTER" : (
!         (CloseButtonProcessor,    "IDOK IDCANCEL"),
          (FolderIDProcessor,       "IDC_FOLDER_WATCH IDC_BROWSE_WATCH",
                                    "Filter.watch_folder_ids",
                                    "Filter.watch_include_sub"),
          (ComboProcessor,          "IDC_ACTION_CERTAIN", "Filter.spam_action"),
- 
          (FolderIDProcessor,       "IDC_FOLDER_CERTAIN IDC_BROWSE_CERTAIN",
                                    "Filter.spam_folder_id"),
          (EditNumberProcessor,     "IDC_EDIT_CERTAIN IDC_SLIDER_CERTAIN",
                                    "Filter.spam_threshold"),
!         
          (FolderIDProcessor,       "IDC_FOLDER_UNSURE IDC_BROWSE_UNSURE",
                                    "Filter.unsure_folder_id"),
--- 260,278 ----
          (AsyncCommandProcessor,   "IDC_START IDC_PROGRESS IDC_PROGRESS_TEXT",
                                    filter.filterer, "Start Filtering", "Stop Filtering",
!                                   "IDOK IDCANCEL IDC_TAB IDC_BUT_UNSEEN IDC_BUT_UNREAD IDC_BROWSE " \
!                                   "IDC_BUT_ACT_SCORE IDC_BUT_ACT_ALL"),
      ),
!     "IDD_FILTER_SPAM" : (
          (FolderIDProcessor,       "IDC_FOLDER_WATCH IDC_BROWSE_WATCH",
                                    "Filter.watch_folder_ids",
                                    "Filter.watch_include_sub"),
          (ComboProcessor,          "IDC_ACTION_CERTAIN", "Filter.spam_action"),
          (FolderIDProcessor,       "IDC_FOLDER_CERTAIN IDC_BROWSE_CERTAIN",
                                    "Filter.spam_folder_id"),
          (EditNumberProcessor,     "IDC_EDIT_CERTAIN IDC_SLIDER_CERTAIN",
                                    "Filter.spam_threshold"),
!         (BoolButtonProcessor,     "IDC_MARK_SPAM_AS_READ",    "Filter.spam_mark_as_read"),
!         ),
!     "IDD_FILTER_UNSURE" : (
          (FolderIDProcessor,       "IDC_FOLDER_UNSURE IDC_BROWSE_UNSURE",
                                    "Filter.unsure_folder_id"),
***************
*** 153,160 ****
          
          (ComboProcessor,          "IDC_ACTION_UNSURE", "Filter.unsure_action"),
!         (DialogCommand,           "IDC_BUT_FILTER_NOW", "IDD_FILTER_NOW"),
!     ),
      "IDD_TRAINING" : (
-         (CloseButtonProcessor,    "IDOK IDCANCEL"),
          (FolderIDProcessor,       "IDC_STATIC_HAM IDC_BROWSE_HAM",
                                    "Training.ham_folder_ids",
--- 281,287 ----
          
          (ComboProcessor,          "IDC_ACTION_UNSURE", "Filter.unsure_action"),
!         (BoolButtonProcessor,     "IDC_MARK_UNSURE_AS_READ",    "Filter.unsure_mark_as_read"),
!         ),
      "IDD_TRAINING" : (
          (FolderIDProcessor,       "IDC_STATIC_HAM IDC_BROWSE_HAM",
                                    "Training.ham_folder_ids",
***************
*** 167,172 ****
          (AsyncCommandProcessor,   "IDC_START IDC_PROGRESS IDC_PROGRESS_TEXT",
                                    train.trainer, "Start Training", "Stop",
!                                   "IDC_BROWSE_HAM IDC_BROWSE_SPAM " \
                                    "IDC_BUT_REBUILD IDC_BUT_RESCORE"),
!     )
  }
--- 294,307 ----
          (AsyncCommandProcessor,   "IDC_START IDC_PROGRESS IDC_PROGRESS_TEXT",
                                    train.trainer, "Start Training", "Stop",
!                                   "IDOK IDCANCEL IDC_TAB IDC_BROWSE_HAM IDC_BROWSE_SPAM " \
                                    "IDC_BUT_REBUILD IDC_BUT_RESCORE"),
!     ),
!     "IDD_ADVANCED" : (
!         (IntProcessor,   "IDC_VERBOSE_LOG",  "General.verbose"),
!         (MsSliderProcessor,   "IDC_DELAY1_TEXT IDC_DELAY1_SLIDER", "Experimental.timer_start_delay"),
!         (MsSliderProcessor,   "IDC_DELAY2_TEXT IDC_DELAY2_SLIDER", "Experimental.timer_interval"),
!         (BoolButtonProcessor,   "IDC_INBOX_TIMER_ONLY", "Experimental.timer_only_receive_folders"),
!         (ComboProcessor,          "IDC_DEL_SPAM_RS", "General.delete_as_spam_message_state"),
!         (ComboProcessor,          "IDC_RECOVER_RS", "General.recover_from_spam_message_state"),
!         )
  }





More information about the Spambayes-checkins mailing list