home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 107 / af107sub.adf / gui4cli.LZX / Gui4Cli / Dir / Dir.g < prev    next >
Text File  |  2003-12-15  |  9KB  |  405 lines

  1. G4C  
  2.  
  3. ; This file contains the 3 pop-up on Right-Mouse-Button click GUIs.
  4.  
  5.  
  6. ;#########################################################################
  7.  
  8. ; This is the RMB pop-up gui (i.e. pops up on clicking the Right Mouse Button)
  9.  
  10. WinBig 0 0 80 105 ""
  11. WinType 00001000
  12. winonmouse 30 22 
  13. varpath dir.gc
  14.  
  15. xOnRMB 
  16. guiclose Dir.g
  17.  
  18. xOnInactive
  19. guiclose Dir.g
  20.  
  21. xOnOpen                ; upon opening the window
  22. id = $$lv.id            ; get the listview's id
  23. if $id < 1
  24.    id = 1
  25. endif
  26. if $id = 2            ; set the copy/move gadgets pointing
  27.    setgad Dir.g 1 HIDE            ; correctly according to the LV's id.
  28.    setgad Dir.g 2 HIDE
  29.    setgad Dir.g 11 show
  30.    setgad Dir.g 22 show
  31.    destid  = 1              ; store destination lv id
  32. else
  33.    setgad Dir.g 11 HIDE
  34.    setgad Dir.g 22 HIDE
  35.    setgad Dir.g 1 show
  36.    setgad Dir.g 2 show
  37.    destid = 2
  38. endif
  39. redraw Dir.g
  40. lvuse dir.gc $destid        ; use the destination lv
  41. destdir = $$lv.dir        ; store the destination dir
  42. lvuse dir.gc $id        ; restore the source lv
  43.  
  44. ;=============================== Next GUI button
  45.  
  46. xbutton 0 0 0 15 More..
  47. guiopen Dir.g3            ; open an other gui with more options
  48. guiclose Dir.g
  49.  
  50. ;=============================== copy button
  51.  
  52. xbutton 0 15 0 15 Copy->
  53. gadhelp 'Copy files from LEFT to RIGHT listview'
  54. gadid 1
  55. gosub Dir.g copy
  56.  
  57. xbutton 0 15 0 15 <-Copy
  58. gadhelp 'Copy files from RIGHT to LEFT listview'
  59. gadid 11
  60. gosub Dir.g copy
  61.  
  62. xroutine copy
  63. guiclose Dir.g
  64. lvaction copy $destdir                  ; copy all selected files/dirs
  65. lvuse dir.gc $destid
  66. lvdir refresh                   ; refresh destination
  67.  
  68. ;============================= copy new files (same logic as copy)
  69.  
  70. xbutton 0 30 0 15 "Copy New"
  71. gadhelp 'Only copy newer files'
  72. guiclose Dir.g
  73. lvaction copynew $destdir        ; same as copy, above
  74. lvuse dir.gc $destid
  75. lvdir refresh
  76.  
  77. ;=============================== Move (same logic as copy)
  78.  
  79. xbutton 0 45 0 15 Move->
  80. gadhelp 'Move selected files'
  81. gadid 2
  82. gosub Dir.g move
  83.  
  84. xbutton 0 45 0 15 <-Move
  85. gadhelp 'Move selected files'
  86. gadid 22
  87. gosub Dir.g move
  88.  
  89. xroutine move
  90. guiclose Dir.g
  91. lvaction move $destdir
  92. lvuse dir.gc $destid
  93. lvdir refresh
  94.  
  95.  
  96. ;============================== delete
  97.  
  98. xbutton 0 60 0 15 Delete
  99. gadhelp 'Delete selected Files/Directories'
  100. guiclose Dir.g
  101. lvaction delete REQ
  102.  
  103.  
  104. ;============================= rename
  105. ; This routine reads the dir listview in the normal first/next method
  106. ; using the lvmulti command and passes the files to guis:tools/rtn/GetString
  107. ; GetString calls the routine "ren" for every file..
  108.  
  109. xbutton 0 75 0 15 Rename
  110. gadhelp 'Rename selected files'
  111. guiclose Dir.g
  112. lvuse dir.gc $id
  113. lvmulti first              ; get the first record
  114. renfile = $dir.gc/lv_file  ; store name to be safe
  115. if $renfile > ' '
  116.    guiload guis:tools/rtn/GetString "Rename $renfile :" "$renfile" dir.g ren multi
  117. endif
  118.  
  119. xRoutine ren newname
  120. rename $renfile $newname
  121. lvuse dir.gc $id
  122. lvmulti off
  123. extract newname file newname
  124. lvput $newname
  125. lvmulti next               ; get the next record
  126. renfile = $dir.gc/lv_file  
  127. if $renfile > ' '
  128.    guiload guis:tools/rtn/GetString "Rename $renfile :" "$renfile" dir.g ren multi
  129. else
  130.    lvdir refresh
  131.    guiquit GetString
  132. endif
  133.  
  134.  
  135. ;============================== makedir
  136.  
  137. xbutton 0 90 0 15 MakeDir
  138. gadhelp 'Create a Directory'
  139. tempdir = $$lv.dir
  140. if $tempdir[-1][1] = ":"     ; add the / if not a device
  141. or $tempdir[-2][2] = ':\"'   ; taking care of quotes
  142.    ;
  143. elseif $tempdir[-1][1] = '\"'
  144.    tempdir[-1][1] = '/'
  145.    appvar tempdir '\"'
  146. else
  147.    appvar tempdir '/'
  148. endif
  149. guiload guis:tools/rtn/GetString "Create Directory:" "$dir.g/tempdir" dir.g mkdir
  150.  
  151. xroutine mkdir     ; called by getstring as above
  152. makedir $$arg.0
  153. lvdir refresh      ; hoping it's still the same listview..
  154.  
  155.  
  156. ;#########################################################################
  157.  
  158. NEWFILE dir.g3    ; The more.. gui (from the RMB pop-up gui)
  159.  
  160.  
  161. WinBig 0 0 160 105 ""
  162. WinType 00001000
  163. winonmouse 50 8 
  164. varpath dir.gc/cli.gc/fsearch.gc
  165.  
  166. xOnRMB 
  167. guiclose Dir.g3
  168.  
  169. xOnInactive
  170. guiclose Dir.g3
  171.  
  172. xOnOpen
  173. id = $$LV.ID           ; Get the id of the current lvdir
  174.  
  175. xOnClose
  176. setwintitle dir.g3 ""     ; because ezreq will change the wintitle..
  177.  
  178.  
  179. ;================================ buttons (left bank)
  180.  
  181. xbutton 0 0 40 15  <<        ; previous
  182. guiopen dir.g
  183. guiclose dir.g3
  184.  
  185. xbutton 40 0 40 15  >>        ; next
  186. guiopen dir.g4
  187. guiclose dir.g3
  188.  
  189. xbutton 0 15 80 15 View
  190. gadhelp 'View selected files according to their type'
  191. guiclose dir.g3
  192. lvuse dir.gc $id
  193. lvmulti first
  194. while $lv_file > ""
  195.     guiload guis:tools/rtn/getfiletype $dir.gc/lv_file
  196.     filetype = $$ret.0
  197.     if $filetype != NONE
  198.        guiload guis:tools/rtn/ViewFile $dir.gc/lv_file $dir.g3/filetype CLI
  199.     endif
  200.     lvmulti next
  201. endwhile
  202.  
  203. xbutton 0 30 80 15 Protect
  204. gadhelp 'Protect selected files'
  205. guiclose dir.g3
  206. guiload  :dir.prot
  207. guiopen  dir.prot
  208.  
  209. xbutton 0 45 80 15 Size
  210. gadhelp 'Show & sum size of selected items'
  211. guiclose dir.g3
  212. lvuse dir.gc $id
  213. lvaction SIZE lv_size
  214. SetWinTitle dir.gc '$lv_size bytes of $$lv.dir                           '
  215.  
  216. xbutton 0 60 80 15 Assign
  217. gadhelp 'Assign Current directory'
  218. tempdir = $$lv.dir
  219. guiclose dir.g3
  220. guiload guis:tools/rtn/GetString "Assign $dir.g3/tempdir as:" "" dir.g3 asn
  221.  
  222. xroutine asn        ; called by getstring as above
  223. assign $$arg.0 $tempdir
  224.  
  225. xbutton 0 75 80 15 'CliGui'
  226. gadhelp 'Open Guis:tools/cli.gc'
  227. cd $$lv.dir
  228. guiclose dir.g3
  229. guiload guis:tools/cli.gc  "" CLI  ; will open itself
  230.  
  231. xbutton 0 90 80 15 Shell
  232. gadhelp 'Open a new Shell'
  233. guiclose dir.g3
  234. cd $$LV.DIR
  235. run 'newshell "con:0/150/680/120/Gui4Cli/auto/close"'
  236.  
  237.  
  238. ; ------------------ Buttons right bank
  239.  
  240. xbutton 80  0 80 15 User..
  241. gadhelp 'Open the Dir/Dir.user pop-up gui'
  242. guiload :dir.user
  243. guiclose dir.g3
  244.  
  245. xbutton 80 15 80 15 Search
  246. gadhelp 'Search for files and/or text in current dir'
  247. guiclose dir.g3
  248. ; store it here, because gui has lv and will loose it..
  249. spath = $$lv.dir
  250. guiload guis:g4c/fsearch/fsearch.gc $dir.g3/spath
  251.  
  252. xbutton 80 30 80 15 Replace
  253. gadhelp 'Replace text in selected files'
  254. guiclose dir.g3
  255. guiload  :dir.rep
  256. guiopen  dir.rep
  257.  
  258. xbutton 80 45 80 15 ReWrap
  259. gadhelp 'Re-Wrap selected files'
  260. guiclose dir.g3
  261. guiload :dir.wrap
  262.  
  263. xbutton 80 60 80 15 "AddIcon"
  264. gadhelp 'Add icons (if icon for file type exists in guis:tools/icons/def)'
  265. guiclose dir.g3
  266. lvuse dir.gc $id
  267. lvmulti first
  268. while $lv_file > ''
  269.    if $lv_file[-1][1] = '\"'  ; care for possible quotes
  270.       fname = $lv_file
  271.       fname[-1][1] = '.'
  272.       fname = '$fname\info\"'
  273.    else
  274.       fname = $lv_file\.info
  275.    endif
  276.    if $$lv.type == DIR
  277.       copy guis:tools/icons/def/DRAWER.info $fname
  278.    else
  279.       guiload guis:tools/rtn/getfiletype $dir.gc/lv_file
  280.       filetype = $$ret.0
  281.       infoname = "guis:tools/icons/def/$filetype\.info"
  282.       ifexists file $infoname
  283.          copy $infoname $fname
  284.       endif
  285.    endif
  286.    lvmulti off
  287.    lvmulti next
  288. endwhile
  289. lvdir refresh
  290.  
  291. xbutton 80 75 80 15 "Select"
  292. guiload guis:tools/rtn/GetString "Enter substring to select:" "" dir.g3 select
  293.  
  294. xroutine select     ; called by select as above
  295. guiclose dir.g3
  296. pat = $$arg.0
  297. lvsearch '$pat' ci first
  298. while $$lv.line > ''
  299.    lvmulti on
  300.    lvsearch '$pat' ci next
  301. endwhile
  302.  
  303.  
  304. xbutton 80 90 80 15 ""
  305.  
  306.  
  307.  
  308. ;#########################################################################
  309.  
  310. NEWFILE dir.g4    ; The more->more.. gui (from the RMB pop-up gui)
  311.                   ; Define your own functions here...
  312.  
  313. WinBig 0 0 160 105 ""
  314. WinType 00001000
  315. winonwin Dir.g3 0 0 
  316. varpath dir.gc
  317.  
  318. xOnRMB 
  319. guiclose Dir.g4
  320.  
  321. xOnInactive
  322. guiclose Dir.g4
  323.  
  324.  
  325. ;================================ buttons (left bank)
  326.  
  327. xbutton 0 0 80 15  <<
  328. guiopen dir.g3
  329. guiclose dir.g4
  330.  
  331. xbutton 0 15 80 15 Calc
  332. gadhelp 'Load Guis:tools/calc.gc'
  333. guiclose dir.g4
  334. guiload guis:tools/calc.gc
  335.  
  336. xbutton 0 30 80 15 Lock
  337. gadhelp 'Load Guis:tools/lock.gc'
  338. guiclose dir.g4
  339. guiload :dir.lock
  340.  
  341. xbutton 0 45 80 15 PPShow
  342. gadhelp 'Open Gui for the PPShow graphics player'
  343. guiclose dir.g4
  344. guiload :dir.ppshow
  345.  
  346. xbutton 0 60 80 15 'Palette'
  347. gadhelp 'Opens the Palette gui'
  348. guiclose dir.g3
  349. guiload  guis:tools/palette.gc
  350.  
  351. xbutton 0 75 80 15 GfxCon
  352. gadhelp 'Opens gui for GfxCon picture converter'
  353. guiclose dir.g4
  354. guiload :dir.gfxcon
  355.  
  356. xbutton 0 90 80 15 Avail
  357. gadhelp 'Opens Gui for showing memory usage'
  358. guiclose dir.g4
  359. guiload :dir.avail
  360.  
  361. ; ------------------ Buttons right bank
  362.  
  363. xbutton 80  0 80 15 'LHa Pack'
  364. gadhelp 'Pack Selected files' 
  365. guiclose dir.g4
  366. guiload :dir.lha
  367.  
  368. xbutton 80 15 80 15 'XPK'
  369. gadhelp 'Load gui for XPK packers'
  370. guiclose dir.g4
  371. guiload :dir.xpack
  372.  
  373. xbutton 80 30 80 15 ""
  374.  
  375. xbutton 80 45 80 15 "GuiEdit"    ; start up a gui editor kind of thing..
  376. gadhelp "Open gui with gadgets for copying (it'll get better..)"
  377. guiclose dir.g4
  378. guiload guis:tools/guiedit.gc
  379. guiopen guiedit.gc
  380.  
  381. xbutton 80 60 80 15 Config
  382. gadhelp 'Loads the configuration gui'
  383. guiclose dir.g4
  384. guiload guis:tools/config.gc
  385.  
  386. xbutton 80 75 80 15 Help
  387. gadhelp 'Loads the dir.gc guide'
  388. extract dir.gc guipath lv_path
  389. joinfile $lv_path dir.guide lv_guide
  390. run '$*DEF.GUIDE $lv_guide'
  391. delvar lv_path
  392. delvar lv_guide
  393.  
  394. xbutton 80 90 80 15 Quit
  395. guiclose dir.g4
  396. ezreq "QUIT ???!!..\nWho, me ?\n" 'DIE!|Well..' lv_ask
  397. if $lv_ask = 1
  398.    guiquit dir.gc
  399. endif
  400.  
  401. ; the pop-up on double-click guis have been moved to file guis:dir/dir.g2
  402.  
  403.  
  404.  
  405.