change the dir field of the multi file search dialog
into a combo-field Initial version of this commit from Kieron Hardy
This commit is contained in:
parent
86522a1804
commit
ec05ecf558
|
@ -550,17 +550,15 @@
|
||||||
(λ (x) (and (pair? x)
|
(λ (x) (and (pair? x)
|
||||||
(number? (car x))
|
(number? (car x))
|
||||||
(number? (cdr x)))))
|
(number? (cdr x)))))
|
||||||
|
(drr:set-default 'drracket:multi-file-search:directories
|
||||||
|
'()
|
||||||
|
(lambda (x) (and (list? x) (andmap string? x))))
|
||||||
(drr:set-default 'drracket:multi-file-search:directory
|
(drr:set-default 'drracket:multi-file-search:directory
|
||||||
;; The default is #f because
|
;; The default is #f because
|
||||||
;; filesystem-root-list is expensive under Windows
|
;; filesystem-root-list is expensive under Windows
|
||||||
#f
|
#f
|
||||||
(lambda (x) (or (not x) (path? x))))
|
(lambda (x) (or (not x) (string? x))))
|
||||||
(preferences:set-un/marshall
|
|
||||||
'drracket:multi-file-search:directory
|
|
||||||
(λ (v) (and v (path->string v)))
|
|
||||||
(λ (p) (if (path-string? p)
|
|
||||||
(string->path p)
|
|
||||||
#f)))
|
|
||||||
|
|
||||||
(drr:set-default 'drracket:large-letters-font #f (λ (x)
|
(drr:set-default 'drracket:large-letters-font #f (λ (x)
|
||||||
(or (and (pair? x)
|
(or (and (pair? x)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
mred
|
mred
|
||||||
racket/file
|
racket/file
|
||||||
racket/path
|
racket/path
|
||||||
|
racket/list
|
||||||
mzlib/thread
|
mzlib/thread
|
||||||
mzlib/async-channel
|
mzlib/async-channel
|
||||||
string-constants
|
string-constants
|
||||||
|
@ -375,8 +376,15 @@
|
||||||
(define method-panel (make-object vertical-panel% method-inset-outer-panel))
|
(define method-panel (make-object vertical-panel% method-inset-outer-panel))
|
||||||
|
|
||||||
(define dir-panel (make-object horizontal-panel% files-panel))
|
(define dir-panel (make-object horizontal-panel% files-panel))
|
||||||
(define dir-field (make-object text-field% (string-constant mfs-dir) dir-panel
|
(define dir-field
|
||||||
(λ (x y) (dir-field-callback))))
|
(new combo-field%
|
||||||
|
[parent dir-panel]
|
||||||
|
[label (string-constant mfs-dir)]
|
||||||
|
[choices (preferences:get 'drracket:multi-file-search:directories)]
|
||||||
|
[stretchable-width #t]
|
||||||
|
[stretchable-height #f]
|
||||||
|
[callback (λ (x y) (dir-field-callback))]))
|
||||||
|
|
||||||
(define dir-button (make-object button% (string-constant browse...) dir-panel
|
(define dir-button (make-object button% (string-constant browse...) dir-panel
|
||||||
(λ (x y) (dir-button-callback))))
|
(λ (x y) (dir-button-callback))))
|
||||||
|
|
||||||
|
@ -440,6 +448,13 @@
|
||||||
[(with-handlers ([exn:fail:filesystem?
|
[(with-handlers ([exn:fail:filesystem?
|
||||||
(λ (x) #f)])
|
(λ (x) #f)])
|
||||||
(directory-exists? (send dir-field get-value)))
|
(directory-exists? (send dir-field get-value)))
|
||||||
|
|
||||||
|
(let ([df (send dir-field get-value)])
|
||||||
|
(when (path-string? df)
|
||||||
|
(define new-l (cons df (remove df (preferences:get 'drracket:multi-file-search:directories))))
|
||||||
|
(preferences:set 'drracket:multi-file-search:directories
|
||||||
|
(take new-l (min (length new-l) 10)))))
|
||||||
|
|
||||||
(let ([_searcher
|
(let ([_searcher
|
||||||
((search-type-make-searcher (list-ref search-types (send methods-choice get-selection)))
|
((search-type-make-searcher (list-ref search-types (send methods-choice get-selection)))
|
||||||
(map (λ (cb) (send cb get-value))
|
(map (λ (cb) (send cb get-value))
|
||||||
|
@ -482,7 +497,7 @@
|
||||||
(define (dir-field-callback)
|
(define (dir-field-callback)
|
||||||
(let ([df (send dir-field get-value)])
|
(let ([df (send dir-field get-value)])
|
||||||
(when (path-string? df)
|
(when (path-string? df)
|
||||||
(preferences:set 'drracket:multi-file-search:directory (string->path df)))))
|
(preferences:set 'drracket:multi-file-search:directory df))))
|
||||||
|
|
||||||
(define (filter-check-box-callback)
|
(define (filter-check-box-callback)
|
||||||
(preferences:set 'drracket:multi-file-search:filter? (send filter-check-box get-value))
|
(preferences:set 'drracket:multi-file-search:filter? (send filter-check-box get-value))
|
||||||
|
@ -510,8 +525,9 @@
|
||||||
old-d)))
|
old-d)))
|
||||||
(when (and new-d
|
(when (and new-d
|
||||||
(directory-exists? new-d))
|
(directory-exists? new-d))
|
||||||
(preferences:set 'drracket:multi-file-search:directory new-d)
|
(define str (path->string new-d))
|
||||||
(send dir-field set-value (path->string new-d))))
|
(preferences:set 'drracket:multi-file-search:directory str)
|
||||||
|
(send dir-field set-value str)))
|
||||||
|
|
||||||
(define (get-files)
|
(define (get-files)
|
||||||
(let ([dir (string->path (send dir-field get-value))])
|
(let ([dir (string->path (send dir-field get-value))])
|
||||||
|
@ -534,13 +550,11 @@
|
||||||
(send filter-check-box set-value (preferences:get 'drracket:multi-file-search:filter?))
|
(send filter-check-box set-value (preferences:get 'drracket:multi-file-search:filter?))
|
||||||
(send search-text-field set-value (preferences:get 'drracket:multi-file-search:search-string))
|
(send search-text-field set-value (preferences:get 'drracket:multi-file-search:search-string))
|
||||||
(send filter-text-field set-value (preferences:get 'drracket:multi-file-search:filter-regexp))
|
(send filter-text-field set-value (preferences:get 'drracket:multi-file-search:filter-regexp))
|
||||||
(send dir-field set-value (path->string
|
(send dir-field set-value (let ([p (preferences:get 'drracket:multi-file-search:directory)])
|
||||||
(let ([p (preferences:get 'drracket:multi-file-search:directory)])
|
(or p
|
||||||
(if (not p)
|
(let ([p (path->string (car (filesystem-root-list)))])
|
||||||
(let ([p (car (filesystem-root-list))])
|
(preferences:set 'drracket:multi-file-search:directory p)
|
||||||
(preferences:set 'drracket:multi-file-search:directory p)
|
p))))
|
||||||
p)
|
|
||||||
p))))
|
|
||||||
|
|
||||||
(send outer-method-panel stretchable-height #f)
|
(send outer-method-panel stretchable-height #f)
|
||||||
(send outer-method-panel set-alignment 'left 'center)
|
(send outer-method-panel set-alignment 'left 'center)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user