adjusted the recently opened menu items code so that it does not create all of the menu items as often
This commit is contained in:
parent
68079d738d
commit
0614da5992
|
@ -181,23 +181,43 @@
|
||||||
(let ([recently-opened-files
|
(let ([recently-opened-files
|
||||||
(preferences:get
|
(preferences:get
|
||||||
'framework:recently-opened-files/pos)])
|
'framework:recently-opened-files/pos)])
|
||||||
(for ([item (send menu get-items)]) (send item delete))
|
(unless (menu-items-still-same? recently-opened-files menu)
|
||||||
|
(for ([item (send menu get-items)]) (send item delete))
|
||||||
(for ([recent-list-item recently-opened-files])
|
|
||||||
(let ([filename (car recent-list-item)])
|
(for ([recent-list-item recently-opened-files])
|
||||||
(new menu-item%
|
(new menu-item%
|
||||||
[parent menu]
|
[parent menu]
|
||||||
[label (gui-utils:trim-string
|
[label (recent-list-item->menu-label recent-list-item)]
|
||||||
(regexp-replace* #rx"&" (path->string filename) "\\&\\&")
|
[callback (λ (x y) (open-recent-list-item recent-list-item))]))
|
||||||
200)]
|
(new separator-menu-item% [parent menu])
|
||||||
[callback (λ (x y) (open-recent-list-item recent-list-item))])))
|
(new menu-item%
|
||||||
(new separator-menu-item% [parent menu])
|
[parent menu]
|
||||||
(new menu-item%
|
[label (string-constant show-recent-items-window-menu-item)]
|
||||||
[parent menu]
|
[callback (λ (x y) (show-recent-items-window))]))
|
||||||
[label (string-constant show-recent-items-window-menu-item)]
|
|
||||||
[callback (λ (x y) (show-recent-items-window))])
|
|
||||||
(void)))
|
(void)))
|
||||||
|
|
||||||
|
(define (recent-list-item->menu-label recent-list-item)
|
||||||
|
(let ([filename (car recent-list-item)])
|
||||||
|
(gui-utils:trim-string
|
||||||
|
(regexp-replace* #rx"&" (path->string filename) "\\&\\&")
|
||||||
|
200)))
|
||||||
|
|
||||||
|
;; this function must mimic what happens in install-recent-items
|
||||||
|
;; it returns #t if all of the labels of menus are the same, or approximation to
|
||||||
|
;; the menus actually being different
|
||||||
|
(define (menu-items-still-same? recently-opened-files menu)
|
||||||
|
(let ([current-items
|
||||||
|
(map (λ (x) (and (is-a? x labelled-menu-item<%>) (send x get-label)))
|
||||||
|
(send menu get-items))]
|
||||||
|
;; the new-items variable shoudl match up to what install-recent-items actually does when it creates the menu
|
||||||
|
[new-items
|
||||||
|
(append
|
||||||
|
(for/list ([recent-list-item recently-opened-files])
|
||||||
|
(recent-list-item->menu-label recent-list-item))
|
||||||
|
(list #f
|
||||||
|
(string-constant show-recent-items-window-menu-item)))])
|
||||||
|
(equal? current-items new-items)))
|
||||||
|
|
||||||
;; open-recent-list-item : recent-list-item -> void
|
;; open-recent-list-item : recent-list-item -> void
|
||||||
(define (open-recent-list-item recent-list-item)
|
(define (open-recent-list-item recent-list-item)
|
||||||
(let* ([filename (car recent-list-item)]
|
(let* ([filename (car recent-list-item)]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user