G4C

; This is a Full blown File Manager.

; I know it's difficult to follow specially since it consists
; of many GUIs which open-close on their own, but.. hey, it's
; a tough world out there..

; Double clicking on a file causes a routine called ViewFile (called
; through the pop-up gui dir.g) to be executed. This routine is in
; GUIs:demos/routines.g and it's job is to run the file according
; to it's type. The programs that it runs are the programs I have
; (ex: c:ppshow) and prefer. Change them to your liking..



WinBig 20 30 200 200 Devices
WinType 11110001
;WinBackground ICON GUIs:info/Bgnds/Bgnd1 0    ; Try uncommenting this line..


xOnLoad
setvar fm_mode 1
setgad Dir.gc 2 HIDE			; hide the gadgets of the
setgad Dir.gc 10 HIDE			; other half of the window
setgad Dir.gc 11 HIDE
setgad Dir.gc 12 HIDE
setgad Dir.gc 13 HIDE
setgad Dir.gc 14 HIDE
setgad Dir.gc 15 HIDE
setgad Dir.gc 16 HIDE
setgad Dir.gc 17 HIDE
guiopen Dir.gc
guiload guis:G4C/dir/Dir.g			; load the helper guis
guiload guis:G4C/dir/Dir.g2
guiload guis:G4C/dir/Dir.g3
guiload guis:G4C/Rtn/routines.g
guiload guis:demos/cli.gc
setvar lv_fmscreen ""			; start by opening on WB
setvar lvd_all       none		; set our variables
setvar lv_dir1  ""
setvar lv_dir2  ""
setvar lv_current 1

xonquit
guiquit Dir.g			; quit our other guis also
guiquit routines.g
guiquit Dir.g2
guiquit Dir.g3
guiquit cli.gc
guiquit dir.prot
delvar  lv_#?                   ; and delete *all* our variables
delvar  mlv_#?

xOnOpen
SetGad dir.gc 20 OFF

xOnClose 
SetGad dir.gc 20 ON


xAppIcon 0 0 GUIs:G4C/dir.gc DIR.gc lv_app OFF
GadID 20
GuiOpen dir.gc
GuiScreen dir.gc FRONT
if $lv_app > " "
   gosub dir.gc appdir 
endif


xAppWindow  lv_app                 ; The FM is also an AppWindow
gosub dir.gc appdir                ; going to the dir of the icon..


xroutine appdir
setvar lv_current 1
ifexists DIR $lv_app               ; see what you have to do when you
    lvdir dir.gc 1 #$lv_app        ; don't have OR..
    setwintitle dir.gc '$lv_app                                 '
    setvar lv_dir1 $lv_app
    stop
endif
ifexists DOS $lv_app
    lvdir dir.gc 1 #$lv_app
    setwintitle dir.gc '$lv_app                                 '
    setvar lv_dir1 $lv_app
    stop
endif
ifexists FILE $lv_app
    extract lv_app PATH lv_app2
    lvdir dir.gc 1 #$lv_app2
    setwintitle dir.gc '$lv_app2                                 '
    setvar lv_dir1 $lv_app2
    extract lv_app FILE lv_app2
    lvfind dir.gc 1 $lv_app2
    stop
endif



xOnRMB
guiopen Dir.g		; This has the copy, delete etc functions

xOnJump lv_newscreen			; If the user jumps screens
setscreen Dir.g $lv_newscreen		; we have to make the other GUIs
setscreen Dir.g2 $lv_newscreen		; follow also..
setscreen Dir.g3 $lv_newscreen
setscreen cli.gc $lv_newscreen
setvar lv_fmscreen $lv_newscreen        ; the load-when-needed guis need it.


;========================= The Directory ListViews ==================
; Note they both have Hooks which are used to store the current dir
; name to a variable and display it to the user.

;---------> the left side

xListView 0 0 185 0 "" lv_file "" 10 DIR
gadid 1
lvdirhook 1
GadFont topaz.font 8 000        ; CHANGE THIS TO THE FONT YOU LIKE!
guiopen Dir.g2

xLVDirHook 1
setvar lv_dir1 $$LV_DIR		; store the current directory name
setvar lv_current 1
setwintitle Dir.gc '$lv_dir1                                          '   ; show it in the wintitle

;----------> the right side

xListView 200 14 185 186 "" lv_file "" 10 DIR
gadid 2
lvdirhook 2
GadFont topaz.font 8 000        ; CHANGE THIS TO THE FONT YOU LIKE!
guiopen Dir.g2

xLVDirHook 2
setvar lv_dir2 $$LV_DIR		; store the current directory name
setvar lv_current 2
update Dir.gc 10 $lv_dir2   	; show it in xTextIn gadget below

xTextIn 200 0 185 14 "" lv_dir2 "" 140
gadid 10
GadFont topaz.font 8 000
LVDir Dir.gc 2 #$lv_dir2	; you can change the dir from here
setvar lv_current 2

;======================== The Action buttons ==========================

;--------> for the left side (source)

xButton 185 0 15 15 P
LVDir Dir.gc 1 parent
setvar lv_dir1 $$LV_DIR
setwintitle Dir.gc '$lv_dir1                                        '

xButton 185 15 15 15 R
LVDir Dir.gc 1 Root
setvar lv_dir1 $$LV_DIR
setwintitle Dir.gc '$lv_dir1                                        '

xButton 185 30 15 15 D
LVDir Dir.gc 1 Disks
setvar lv_dir1 ""
setwintitle Dir.gc 'Devices'

xButton 185 45 15 15 A
LVDir Dir.gc 1 All

xButton 185 60 15 15 N
LVDir Dir.gc 1 None

xButton 185 155 15 15 R
lvdir Dir.gc 1 Refresh

xButton 185 170 15 15 <			; move list left
lvmove Dir.gc 1 -10

xButton 185 185 15 15 >
lvmove Dir.gc 1 10

;---------> for the right side (destination) give gadID so we set them on/off

xButton 385 0 15 15 P
GadID 11
LVDir Dir.gc 2 parent
setvar lv_dir2 $$LV_DIR
update Dir.gc 10 $lv_dir2

xButton 385 15 15 15 R
gadid 12
LVDir Dir.gc 2 Root
setvar lv_dir2 $$LV_DIR
update Dir.gc 10 $lv_dir2

xButton 385 30 15 15 D
gadid 13
LVDir Dir.gc 2 Disks
setvar lv_dir2 ""
update Dir.gc 10 ""

xButton 385 45 15 15 A
gadid 14
LVDir Dir.gc 2 All

xButton 385 60 15 15 N
gadid 15
LVDir Dir.gc 2 None

xButton 385 155 15 15 R
lvdir Dir.gc 2 Refresh

xButton 385 170 15 15 <		; move list left
GadID 16
lvmove Dir.gc 2 -10

xButton 385 185 15 15 >		; move list right
GadID 17
lvmove Dir.gc 2 10

;---------> open full file manager

xButton 185 90 15 15 >
gadid 21
if $fm_mode = 1
   gosub Dir.gc OpenWindow
else
   gosub Dir.gc CloseWindow
endif


;--------> button to switch left <-> right lvs

xButton 185 105 15 15 x
gadid  20
setvar lv_temp  $lv_dir2		; exchange the var names
setvar lv_dir2 $lv_dir1
setvar lv_dir1 $lv_temp
LVDir Dir.gc 1 #$lv_dir1		; update the listviews
setwintitle Dir.gc '$lv_dir1                                      ' ; and their dir displays
LVDir Dir.gc 2 #$lv_dir2
update Dir.gc 10 $lv_dir2
delvar lv_temp

;--------> same directories

xButton 185 120 15 15 =
if $lv_current = 1
   lvdir dir.gc 2 #$lv_dir1
else
   lvdir dir.gc 1 #$lv_dir2
endif

;---------> ROUTINES

xRoutine OpenWindow		; Routine to enlarge the window
   setvar fm_mode 2
   setgad Dir.gc 2 SHOW
   setgad Dir.gc 10 SHOW
   setgad Dir.gc 11 SHOW
   setgad Dir.gc 12 SHOW
   setgad Dir.gc 13 SHOW
   setgad Dir.gc 14 SHOW
   setgad Dir.gc 15 SHOW
   setgad Dir.gc 16 SHOW
   setgad Dir.gc 17 SHOW
   changearg Dir.gc 21 4 <
   changegad Dir.gc 0 -1 -1 400 200 ""
   redraw Dir.gc
   update Dir.gc 10 $lv_dir2

xRoutine CloseWindow		; make it small again
   setvar fm_mode 1
   setgad Dir.gc 2 HIDE
   setgad Dir.gc 10 HIDE
   setgad Dir.gc 11 HIDE
   setgad Dir.gc 12 HIDE
   setgad Dir.gc 13 HIDE
   setgad Dir.gc 14 HIDE
   setgad Dir.gc 15 HIDE
   setgad Dir.gc 16 HIDE
   setgad Dir.gc 17 HIDE
   changegad Dir.gc 0 -1 -1 200 200 ""
   changearg Dir.gc 21 4 >
   redraw Dir.gc



RESIZE_BIG 154 11 226 250
