@@ -259,7 +259,19 @@ the state transitions / contracts are:
259259 (define on-close-dialog-callbacks null)
260260
261261 (define can-close-dialog-callbacks null)
262-
262+
263+ ;; labels->panel-visibility-thunk : hash[(listof string?) -o> (-> void?)]
264+ ;; maps the sequence of strings naming a path into the preferences
265+ ;; dialog into a function that makes the corresponding panel visible
266+ (define labels->panel-visibility-thunk (make-hash))
267+
268+ (define (show-tab-panel panel-paths)
269+ (show-dialog)
270+ (define pth (hash-ref labels->panel-visibility-thunk panel-paths #f ))
271+ (unless pth
272+ (error 'show-tab-panel "did not find the path\n path: ~e " panel-paths))
273+ (pth))
274+
263275 (define (make-preferences-dialog)
264276 (letrec ([stashed-prefs (preferences:get-prefs-snapshot)]
265277 [cancelled? #f ]
@@ -288,43 +300,55 @@ the state transitions / contracts are:
288300 [label (string-constant preferences)]
289301 [height 200 ])]
290302 [build-ppanel-tree
291- (λ (ppanel tab-panel single-panel)
303+ (λ (ppanel tab-panel single-panel parents thunk )
292304 (send tab-panel append (ppanel-name ppanel))
293305 (cond
294- [(ppanel-leaf? ppanel)
306+ [(ppanel-leaf? ppanel)
307+ (hash-set! labels->panel-visibility-thunk (cons (ppanel-name ppanel) parents) thunk )
295308 ((ppanel-leaf-maker ppanel) single-panel)]
296309 [(ppanel-interior? ppanel)
297- (let-values ([(tab-panel single-panel) (make-tab/single-panel single-panel #t )])
298- (for-each
299- (λ (ppanel) (build-ppanel-tree ppanel tab-panel single-panel))
300- (ppanel-interior-children ppanel)))]))]
310+ (define-values (tab-panel next-single-panel) (make-tab/single-panel single-panel #t ))
311+ (define (next-thunk)
312+ (thunk )
313+ (tab-panel-callback next-single-panel tab-panel))
314+ (for ([child-ppanel (in-list (ppanel-interior-children ppanel))]
315+ [i (in-naturals)])
316+ (build-ppanel-tree child-ppanel tab-panel next-single-panel
317+ (cons (ppanel-name ppanel) parents)
318+ (λ ()
319+ (send tab-panel set-selection i)
320+ (next-thunk))))]))]
301321 [make-tab/single-panel
302322 (λ (parent inset?)
303- (letrec ([spacer (and inset?
304- (instantiate vertical-panel% ()
305- (parent parent)
306- (border 10 )))]
307- [tab-panel (instantiate tab-panel% ()
308- (choices null)
309- (parent (if inset? spacer parent))
310- (callback (λ (_1 _2)
311- (tab-panel-callback
312- single-panel
313- tab-panel))))]
314- [single-panel (instantiate panel:single% ()
315- (parent tab-panel))])
316- (values tab-panel single-panel)))]
323+ (define spacer (and inset?
324+ (new vertical-panel%
325+ [parent parent]
326+ [border 10 ])))
327+ (define tab-panel (new tab-panel%
328+ [choices null]
329+ [parent (if inset? spacer parent)]
330+ [callback (λ (_1 _2)
331+ (tab-panel-callback
332+ single-panel
333+ tab-panel))]))
334+ (define single-panel (new panel:single% [parent tab-panel]))
335+ (values tab-panel single-panel))]
317336 [tab-panel-callback
318337 (λ (single-panel tab-panel)
319338 (send single-panel active-child
320339 (list-ref (send single-panel get-children)
321340 (send tab-panel get-selection))))]
322341 [panel (make-object vertical-panel% (send frame get-area-container))]
323342 [_ (let-values ([(tab-panel single-panel) (make-tab/single-panel panel #f )])
324- (for-each
325- (λ (ppanel)
326- (build-ppanel-tree ppanel tab-panel single-panel))
327- ppanels)
343+ (for ([ppanel (in-list ppanels)]
344+ [i (in-naturals)])
345+ (build-ppanel-tree ppanel tab-panel single-panel
346+ '()
347+ (λ ()
348+ (send tab-panel set-selection i)
349+ (tab-panel-callback
350+ single-panel
351+ tab-panel))))
328352 (let ([single-panel-children (send single-panel get-children)])
329353 (unless (null? single-panel-children)
330354 (send single-panel active-child (car single-panel-children))
0 commit comments