From dd081d9b4e50617580c6fc286a08aa7ebad38b7a Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Tue, 7 Dec 2010 14:29:54 -0600 Subject: [PATCH] added a tabs menu for windows (and linux) --- collects/drracket/private/main.rkt | 7 ++- collects/framework/private/frame.rkt | 12 ++-- collects/framework/private/group.rkt | 60 +++++++++++-------- .../english-string-constants.rkt | 4 +- 4 files changed, 50 insertions(+), 33 deletions(-) diff --git a/collects/drracket/private/main.rkt b/collects/drracket/private/main.rkt index 1f02f3335e..0be0fdddcc 100644 --- a/collects/drracket/private/main.rkt +++ b/collects/drracket/private/main.rkt @@ -670,8 +670,11 @@ (let ([frame (find-frame item)]) (when frame (send frame next-tab))))]) + (let ([frame (find-frame windows-menu)]) (unless (or (not frame) (= 1 (send frame get-tab-count))) + (unless (eq? (system-type) 'macosx) + (new separator-menu-item% [parent windows-menu])) (for ([i (in-range 0 (send frame get-tab-count))] #:when (< i 9)) (new menu-item% @@ -683,7 +686,9 @@ [callback (λ (a b) (send frame change-to-nth-tab i))])))) - (new separator-menu-item% [parent windows-menu])))) + + (when (eq? (system-type) 'macosx) + (new separator-menu-item% [parent windows-menu]))))) ;; Check for any files lost last time. ;; Ignore the framework's empty frames test, since diff --git a/collects/framework/private/frame.rkt b/collects/framework/private/frame.rkt index c42b2d8954..66d63e465b 100644 --- a/collects/framework/private/frame.rkt +++ b/collects/framework/private/frame.rkt @@ -44,7 +44,8 @@ items)) (let* ([file-menu (find-menu (string-constant file-menu))] [edit-menu (find-menu (string-constant edit-menu))] - [windows-menu (find-menu (string-constant windows-menu))] + [windows-menu (or (find-menu (string-constant windows-menu)) + (find-menu (string-constant tabs-menu)))] [help-menu (find-menu (string-constant help-menu))] [other-items (remq* (list file-menu edit-menu windows-menu help-menu) items)] @@ -212,10 +213,11 @@ (set-icon icon (send icon get-loaded-mask) 'both)))) (let ([mb (make-object (get-menu-bar%) this)]) - (when (or (eq? (system-type) 'macos) - (eq? (system-type) 'macosx)) - (make-object menu:can-restore-underscore-menu% (string-constant windows-menu-label) - mb))) + (make-object menu:can-restore-underscore-menu% + (case (system-type) + [(macosx) (string-constant windows-menu-label)] + [else (string-constant tabs-menu-label)]) + mb)) (reorder-menus this) diff --git a/collects/framework/private/group.rkt b/collects/framework/private/group.rkt index 96bd61ff42..81811652dd 100644 --- a/collects/framework/private/group.rkt +++ b/collects/framework/private/group.rkt @@ -30,6 +30,11 @@ (f menu) (old menu))))) + (define windows-menu-label + (case (system-type) + [(macosx) (string-constant windows-menu-label)] + [else (string-constant tabs-menu-label)])) + (define % (class object% @@ -47,8 +52,10 @@ (and menu-bar (let ([menus (send menu-bar get-items)]) (ormap (λ (x) - (if (string=? (string-constant windows-menu) - (send x get-plain-label)) + (if (or (string=? (string-constant windows-menu) + (send x get-plain-label)) + (string=? (string-constant tabs-menu) + (send x get-plain-label))) x #f)) menus))))) @@ -105,33 +112,34 @@ [parent menu] [callback (λ (x y) (let ([frame (send (send menu get-parent) get-frame)]) - (send frame maximize (not (send frame is-maximized?)))))])) - (instantiate menu:can-restore-menu-item% () - (label (string-constant bring-frame-to-front...)) - (parent menu) - (callback (λ (x y) (choose-a-frame (send (send menu get-parent) get-frame)))) - (shortcut #\j)) - (instantiate menu:can-restore-menu-item% () - (label (string-constant most-recent-window)) - (parent menu) - (callback (λ (x y) (most-recent-window-to-front))) - (shortcut #\')) - (make-object separator-menu-item% menu) + (send frame maximize (not (send frame is-maximized?)))))]) + (instantiate menu:can-restore-menu-item% () + (label (string-constant bring-frame-to-front...)) + (parent menu) + (callback (λ (x y) (choose-a-frame (send (send menu get-parent) get-frame)))) + (shortcut #\j)) + (instantiate menu:can-restore-menu-item% () + (label (string-constant most-recent-window)) + (parent menu) + (callback (λ (x y) (most-recent-window-to-front))) + (shortcut #\')) + (make-object separator-menu-item% menu)) (extra-windows-menus-proc menu) - (for-each - (λ (frame) - (let ([frame (frame-frame frame)]) - (make-object menu-item% - (regexp-replace* - #rx"&" - (gui-utils:trim-string (get-name frame) 200) - "&&") - menu - (λ (_1 _2) - (send frame show #t))))) - sorted/visible-frames)) + (when (eq? (system-type) 'macosx) + (for-each + (λ (frame) + (let ([frame (frame-frame frame)]) + (make-object menu-item% + (regexp-replace* + #rx"&" + (gui-utils:trim-string (get-name frame) 200) + "&&") + menu + (λ (_1 _2) + (send frame show #t))))) + sorted/visible-frames))) windows-menus))) ;; most-recent-window-to-front : -> void? diff --git a/collects/string-constants/english-string-constants.rkt b/collects/string-constants/english-string-constants.rkt index 086d1e35ae..84daa5f704 100644 --- a/collects/string-constants/english-string-constants.rkt +++ b/collects/string-constants/english-string-constants.rkt @@ -599,7 +599,8 @@ please adhere to these guidelines: (edit-menu "Edit") (help-menu "Help") (windows-menu "Windows") - + (tabs-menu "Tabs") ;; this is the name of the "Windows" menu under linux & windows + ;;; menus ;;; - in menu labels, the & indicates a alt-key based shortcut. ;;; - sometimes, things are stuck in the middle of @@ -730,6 +731,7 @@ please adhere to these guidelines: ;; windows menu (windows-menu-label "&Windows") + (tabs-menu-label "&Tabs") ;; this is the name of the menu under linux & windows (minimize "Minimize") ;; minimize and zoom are only used under mac os x (zoom "Zoom") (bring-frame-to-front "Bring Frame to Front") ;;; title of dialog