G4C

; This is the trashcan GUI.

; We could (using a listview as a database) with a lot of code 
; & efort, make the trashcan remember the previous path of the
; files trashed, but it's much easier to just let the user tell
; us where he wants them returned to...

; This GUI is simple, and it displays the use of Directory listviews
; very well.


WinBig 20 30 250 197 "TrashCan contents :"
WinType 11110001
WinBackGround icon guis:info/TrashCanEmpty 0    ; gory heh ?

xOnOpen					; refresh dir display
lvdir trashcan.g 1 #TRASH_CAN:
setgad trashcan.g 2 OFF
setvar tc_dir TRASH_CAN:

xOnClose
gosub trashcan.gc SetTrashIcon		; set the correct trash icon

xOnQuit
guiquit trashcan.gc			; also quit the main gui
delvar tc_#?

xMenu Action Quit "" Q
guiquit trashcan.g

;---------------- The Directory ListView

xListView 0 0 170 0 "" tc_file TRASH_CAN: 10 DIR
gadid 1
lvdirhook 1
GadFont topaz.font 8 000
setvar rtn_var $tc_file
gosub  routines.g ViewFile	; a routine to view file according to type


xLvDirHook 1
setvar tc_dir $$LV_DIR
SetWinTitle trashcan.g '$tc_dir                                '
setgad trashcan.g 2 ON

;--------------- All/None Buttons

xButton 170 0 80 20 Parent
gadid 2
LVDir trashcan.g 1 Parent
setvar tc_dir $$LV_DIR
if tc_dir F= TRASH_CAN:         ; do not allow user to parent trash_can:
   setgad trashcan.g 2 OFF
endif


xButton 170 20 80 20 All
LVDir trashcan.g 1 All

xButton 170 40 80 20 None
LVDir trashcan.g 1 None


;-------------- Delete button

xButton 170 100 80 20 DELETE..
lvmulti trashcan.g 1 first		; get first file
if $tc_file = ""			; no files chosen
   stop
endif
lvaction delete trashcan.g 1 REQ        ; delete chosen files


;-------------- Restore button

xButton 170 120 80 20 Restore..
lvmulti trashcan.g 1 first		; get first file
if $tc_file = ""			; no files chosen
   stop					; so stop
endif
setvar tc_restore ""
ReqFile  -1 -1 250 200 "Restore files where ?" DIR tc_restore ""
if $tc_restore > ""
   lvaction move trashcan.g 1 $tc_restore
endif
delvar tc_restore


;-------------- Cancel

xButton 170 177 80 20 OK
guiclose trashcan.g



