adjust the close/close window/close tab menu items to be more like other apps on the various platforms

This commit is contained in:
Robby Findler 2011-09-01 10:52:17 -05:00
parent 8f6fb87597
commit 49dbb5d963
5 changed files with 48 additions and 28 deletions

View File

@ -2974,22 +2974,33 @@ module browser threading seems wrong.
(update-close-menu-item-shortcut (file-menu:get-close-item)))
(define/private (update-close-tab-menu-item-shortcut item)
(let ([just-one? (and (pair? tabs) (null? (cdr tabs)))])
(send item set-label (if just-one?
(string-constant close-tab)
(string-constant close-tab-amp)))
(when (preferences:get 'framework:menu-bindings)
(send item set-shortcut (if just-one? #f #\w)))))
(define just-one? (and (pair? tabs) (null? (cdr tabs))))
(send item set-label (if just-one?
(string-constant close-tab)
(string-constant close-tab-amp)))
(when (preferences:get 'framework:menu-bindings)
(send item set-shortcut (if just-one? #f #\w))))
(define/private (update-close-menu-item-shortcut item)
(let ([just-one? (and (pair? tabs) (null? (cdr tabs)))])
(send item set-label (if just-one?
(string-constant close-menu-item)
(string-constant close)))
(when (preferences:get 'framework:menu-bindings)
(send item set-shortcut-prefix (if just-one?
(get-default-shortcut-prefix)
(cons 'shift (get-default-shortcut-prefix)))))))
(cond
[(eq? (system-type) 'linux)
(send item set-label (string-constant close-menu-item))]
[else
(define just-one? (and (pair? tabs) (null? (cdr tabs))))
(send item set-label (if just-one?
(string-constant close-window-menu-item)
(string-constant close-window)))
(when (preferences:get 'framework:menu-bindings)
(send item set-shortcut-prefix (if just-one?
(get-default-shortcut-prefix)
(cons 'shift (get-default-shortcut-prefix)))))]))
(define/override (file-menu:close-callback item control)
(define just-one? (and (pair? tabs) (null? (cdr tabs))))
(if (and (eq? (system-type) 'linux)
(not just-one?))
(close-current-tab)
(super file-menu:close-callback item control)))
;; offer-to-save-file : path -> void
;; bring the tab that edits the file named by `path' to the front
@ -3330,16 +3341,17 @@ module browser threading seems wrong.
(make-object separator-menu-item% file-menu))]
(define close-tab-menu-item #f)
(define/override (file-menu:between-close-and-quit file-menu)
(set! close-tab-menu-item
(new (get-menu-item%)
(label (string-constant close-tab))
(demand-callback
(λ (item)
(send item enable (1 . < . (send tabs-panel get-number)))))
(parent file-menu)
(callback
(λ (x y)
(close-current-tab)))))
(unless (eq? (system-type) 'linux)
(set! close-tab-menu-item
(new (get-menu-item%)
(label (string-constant close-tab))
(demand-callback
(λ (item)
(send item enable (1 . < . (send tabs-panel get-number)))))
(parent file-menu)
(callback
(λ (x y)
(close-current-tab))))))
(super file-menu:between-close-and-quit file-menu))
(define/override (file-menu:save-string) (string-constant save-definitions))

View File

@ -265,7 +265,9 @@
'(λ (item control) (when (can-close?) (on-close) (show #f)) #t)
#\w
'(get-default-shortcut-prefix)
'(string-constant close-menu-item)
'(if (eq? (system-type) 'linux)
(string-constant close-menu-item)
(string-constant close-window-menu-item))
on-demand-do-nothing
#t)
(make-between 'file-menu 'close 'quit 'nothing)

View File

@ -272,7 +272,11 @@
file-menu:close-callback
(λ (item control) (when (can-close?) (on-close) (show #f)) #t))
(define/public (file-menu:get-close-item) file-menu:close-item)
(define/public (file-menu:close-string) (string-constant close-menu-item))
(define/public
(file-menu:close-string)
(if (eq? (system-type) 'linux)
(string-constant close-menu-item)
(string-constant close-window-menu-item)))
(define/public (file-menu:close-help-string) (string-constant close-info))
(define/public file-menu:close-on-demand (λ (menu-item) (void)))
(define/public (file-menu:create-close?) #t)

View File

@ -118,7 +118,7 @@
@(defmethod (file-menu:close-on-demand (menu-item (is-a?/c menu-item%))) void? "The menu item's on-demand proc calls this method." "\n" "\n" "Defaults to " (racketblock (void)))
@(defmethod (file-menu:close-string) string? "The result of this method is used as the name of the " (racket menu-item%) "." "\n" "\n" "Defaults to " (racket (string-constant close-menu-item)) ".")
@(defmethod (file-menu:close-string) string? "The result of this method is used as the name of the " (racket menu-item%) "." "\n" "\n" "Defaults to " (racket (if (eq? (system-type) (quote linux)) (string-constant close-menu-item) (string-constant close-window-menu-item))) ".")
@(defmethod (file-menu:close-help-string) string? "The result of this method is used as the help string" "\n" "when the " (racket menu-item%) " object is created." "\n" "\n" "Defaults to " (racket (string-constant close-info)) ".")

View File

@ -113,9 +113,10 @@ please adhere to these guidelines:
(untitled-n "Untitled ~a")
(warning "Warning")
(error "Error")
(close "Close") ;; as in, close an open window. must match close-menu-item
(close "Close") ;; as in, close an open window or tab. must match close-menu-item
;; in the sense that, when the &s have been stripped from
;; close-menu-item, it must be the same string as this.
(close-window "Close Window")
(stop "Stop")
(&stop "&Stop") ;; for use in button and menu item labels, with short cut.
(are-you-sure-delete? "Are you sure you want to delete ~a?") ;; ~a is a filename or directory name
@ -674,6 +675,7 @@ please adhere to these guidelines:
(close-info "Close this file")
(close-menu-item "&Close")
(close-window-menu-item "&Close Window")
(quit-info "Close all windows")
(quit-menu-item-windows "E&xit")