diff --git a/twander.py b/twander.py index f932802..a105943 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 3.120 2003/03/01 22:03:59 tundra Exp $" +RCSID = "$Id: twander.py,v 3.121 2003/03/02 00:52:06 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -325,12 +325,11 @@ dlvTOTAL = "Total Space" dlvLETTER = "Drive Letter" -# 'Fake' sorting fields used to set SORTREVERSE and SORTSEPARATE +# 'Fake' sorting field used to set SORTREVERSE and SORTSEPARATE fREVERSE = -1 fSEPARATE = -2 - # Associate each legal field name with the corresponding sortkey field position # Note that fNONE indicates that no sorting is to be done, so there # is no real associated sortkey field. @@ -339,7 +338,7 @@ index = -1 for x, y in [(fNONE, dlvNONE), (fPERMISSIONS, dlvLABEL), (fLINKS, dlvTYPE), (fOWNER, dlvFREE), - (fGROUP, dlvTOTAL), (fLENGTH, dlvLETTER), (fDATE, dlvLETTER), (fNAME, dlvLETTER)]: + (fGROUP, dlvTOTAL), (fLENGTH, dlvLETTER), (fDATE, dlvLETTER), (fNAME, dlvLETTER)]: Name2Key[x.lower()] = (index, y) index += 1 @@ -608,11 +607,22 @@ # Menu Button Titles -COMMANDMENU = 'Commands' # Title for Command Menu button -DIRMENU = 'Directories' # Title for Directory Menu button -HISTMENU = 'History' # Title for History Menu button -WILDMENU = 'Wildcards' # Title for Wildcard Menu button -HELPMENU = 'Help' # Title for Help Menu button +COMMANDMENU = 'Commands' # Title for Command Menu button +DIRMENU = 'Directories' # Title for Directory Menu button +HISTMENU = 'History' # Title for History Menu button +SORTMENU = 'Sorting' # Title for Sort Menu button +WILDMENU = 'Wildcards' # Title for Wildcard Menu button +HELPMENU = 'Help' # Title for Help Menu button + +# Sort Menu-Related + +# And their names - used in Sorting Menu + +sSORTBY = "Sort By" +sREVERSE = "Reverse Sort" +sSEPARATE = "Separate Dirs/Files" + + # Help Menu-Related @@ -1401,7 +1411,7 @@ # Any user-set options have now been read, set the GUI - for i in (UI.CmdBtn, UI.DirBtn, UI.HistBtn, UI.WildBtn, UI.HelpBtn): + for i in (UI.CmdBtn, UI.DirBtn, UI.HistBtn, UI.SortBtn, UI.WildBtn, UI.HelpBtn): i.config(foreground=MFCOLOR, background=MBCOLOR, font=(MFNAME, MFSZ, MFWT)) i.menu.config(foreground=MFCOLOR, background=MBCOLOR, font=(MFNAME, MFSZ, MFWT)) @@ -1417,7 +1427,42 @@ UpdateMenu(UI.DirBtn, UI.AllDirs, MAXMENU, MAXMENUBUF, LoadDirList, sort=TRUE) UpdateMenu(UI.HistBtn, UI.CmdHist, MAXMENU, MAXMENUBUF, KeyRunCommand, fakeevent=TRUE) UpdateMenu(UI.WildBtn, UI.WildHist, MAXMENU, MAXMENUBUF, KeySelWild, fakeevent=TRUE) + + # Setup the sorting menu + # Clear out any old entries + + UI.SortBtn.config(state=DISABLED) + UI.SortBtn.menu.delete(0,END) + + + # Add the menu selections + + UI.SortBtn.menu.add_command(label="%s %s / %s" % (sSORTBY, fNONE, Name2Key[fNONE.lower()][1]), + command=lambda parm=fNONE : KeySetSortParm(parm)) + UI.SortBtn.menu.add_command(label="%s %s / %s" % (sSORTBY, fPERMISSIONS, Name2Key[fPERMISSIONS.lower()][1]), + command=lambda parm=fPERMISSIONS : KeySetSortParm(parm)) + UI.SortBtn.menu.add_command(label="%s %s / %s" % (sSORTBY, fLINKS, Name2Key[fLINKS.lower()][1]), + command=lambda parm=fLINKS : KeySetSortParm(parm)) + UI.SortBtn.menu.add_command(label="%s %s / %s" % (sSORTBY, fOWNER, Name2Key[fOWNER.lower()][1]), + command=lambda parm=fOWNER : KeySetSortParm(parm)) + UI.SortBtn.menu.add_command(label="%s %s / %s" % (sSORTBY, fGROUP, Name2Key[fGROUP.lower()][1]), + command=lambda parm=fGROUP : KeySetSortParm(parm)) + UI.SortBtn.menu.add_command(label="%s %s / %s" % (sSORTBY, fLENGTH, Name2Key[fLENGTH.lower()][1]), + command=lambda parm=fLENGTH : KeySetSortParm(parm)) + UI.SortBtn.menu.add_command(label="%s %s / %s" % (sSORTBY, fDATE, Name2Key[fDATE.lower()][1]), + command=lambda parm=fDATE : KeySetSortParm(parm)) + UI.SortBtn.menu.add_command(label="%s %s / %s" % (sSORTBY, fNAME, Name2Key[fNAME.lower()][1]), + command=lambda parm=fNAME : KeySetSortParm(parm)) + UI.SortBtn.menu.add_command(label="%s" % (sREVERSE), command=lambda parm=fREVERSE : KeySetSortParm(parm)) + UI.SortBtn.menu.add_command(label="%s" % (sSEPARATE), command=lambda parm=fSEPARATE : KeySetSortParm(parm)) + + + # Enable the menu selections + + UI.SortBtn['menu'] = UI.SortBtn.menu + UI.SortBtn.config(state=NORMAL) + # Initialize the Help Menu LoadHelpMenu() @@ -1587,6 +1632,12 @@ self.HistBtn.menu = Menu(self.HistBtn) self.HistBtn.pack(side=LEFT, padx=MENUPADX) + # Setup the Sort Menu + + self.SortBtn = Menubutton(self.mBar, text=SORTMENU, underline=0, state=DISABLED) + self.SortBtn.menu = Menu(self.SortBtn) + self.SortBtn.pack(side=LEFT, padx=MENUPADX) + # Setup the Wildcard Menu self.WildBtn = Menubutton(self.mBar, text=WILDMENU, underline=0, state=DISABLED)