get rid of the "open here" functionality

This is a backwards incompatible change; there is a more complex change
that just stubs this stuff out that may be better that we may need
isntead of this commit.
This commit is contained in:
Robby Findler 2011-09-21 22:50:24 -05:00
parent c264ece3f4
commit 048fa1d7b8
25 changed files with 18 additions and 260 deletions

View File

@ -26,8 +26,7 @@ remain the same for tools that use them.
(define unit:frame<%>
(interface (frame:<%>
frame:searchable-text<%>
frame:delegate<%>
frame:open-here<%>)
frame:delegate<%>)
get-insert-menu
get-special-menu
get-interactions-text

View File

@ -1298,7 +1298,7 @@ module browser threading seems wrong.
show-planet-status)
(define frame-mixin
(mixin (drracket:frame:<%> frame:searchable-text<%> frame:delegate<%> frame:open-here<%>)
(mixin (drracket:frame:<%> frame:searchable-text<%> frame:delegate<%>)
(drracket:unit:frame<%>)
(init filename)
(inherit set-label-prefix get-show-menu
@ -2717,7 +2717,6 @@ module browser threading seems wrong.
(set! definitions-canvas (create-definitions-canvas))))
(define/override (get-delegated-text) definitions-text)
(define/override (get-open-here-editor) definitions-text)
;; wire the definitions text to the interactions text and initialize it.
(define/private (init-definitions-text tab)
@ -4797,13 +4796,12 @@ module browser threading seems wrong.
(frame:status-line-mixin
(frame:info-mixin
(frame:text-mixin
(frame:open-here-mixin
(frame:editor-mixin
(frame:standard-menus-mixin
(frame:register-group-mixin
(frame:focus-table-mixin
(frame:basic-mixin
frame%)))))))))))))))))))
(frame:editor-mixin
(frame:standard-menus-mixin
(frame:register-group-mixin
(frame:focus-table-mixin
(frame:basic-mixin
frame%))))))))))))))))))
(define-local-member-name enable-two-way-prefs)
(define (make-two-way-prefs-dragable-panel% % pref-key)

View File

@ -838,14 +838,7 @@
((filename)
((make-default
(λ () ((handler:current-create-new-window) filename)))))
@{This function creates a frame or re-uses an existing frame to edit a file.
If the preference @racket['framework:open-here] is set to @racket[#t], and
@racket[(send (group:get-the-frame-group) get-open-here-frame)] returns a
frame, the @method[frame:open-here<%> open-here] method of that frame is
used to load the file in the existing frame.
Otherwise, it invokes the appropriate format handler to open the file (see
@{This function invokes the appropriate format handler to open the file (see
@racket[handler:insert-format-handler]).
@itemize[

View File

@ -1453,128 +1453,6 @@
;; it might not yet be implemented
(send canvas focus)))))
(define open-here<%>
(interface (-editor<%>)
get-open-here-editor
open-here))
(define open-here-mixin
(mixin (-editor<%>) (open-here<%>)
(define/override (file-menu:new-on-demand item)
(super file-menu:new-on-demand item)
(send item set-label (if (preferences:get 'framework:open-here?)
(string-constant new-...-menu-item)
(string-constant new-menu-item))))
(define/override (file-menu:new-callback item event)
(cond
[(preferences:get 'framework:open-here?)
(let ([clear-current (ask-about-new-here)])
(cond
[(eq? clear-current 'cancel) (void)]
[clear-current
(let* ([editor (get-editor)]
[canceled? (cancel-due-to-unsaved-changes editor)])
(unless canceled?
(send editor begin-edit-sequence)
(send editor lock #f)
(send editor set-filename #f)
(send editor erase)
(send editor set-modified #f)
(send editor clear-undos)
(send editor end-edit-sequence)))]
[else ((handler:current-create-new-window) #f)]))]
[else ((handler:current-create-new-window) #f)]))
;; cancel-due-to-unsaved-changes : -> boolean
;; returns #t if the action should be cancelled
(define/private (cancel-due-to-unsaved-changes editor)
(and (send editor is-modified?)
(let ([save (gui-utils:unsaved-warning
(let ([fn (send editor get-filename)])
(if fn
(path->string fn)
(get-label)))
(string-constant clear-anyway)
#t
this)])
(case save
[(continue) #f]
[(save) (not (send editor save-file/gui-error))]
[(cancel) #t]))))
;; ask-about-new-here : -> (union 'cancel boolean?)
;; prompts the user about creating a new window
;; or "reusing" the current one.
(define/private (ask-about-new-here)
(gui-utils:get-choice
(string-constant create-new-window-or-clear-current)
(string-constant clear-current)
(string-constant new-window)
(string-constant warning)
'cancel
this))
(define/override (file-menu:open-on-demand item)
(super file-menu:open-on-demand item)
(send item set-label (if (preferences:get 'framework:open-here?)
(string-constant open-here-menu-item)
(string-constant open-menu-item))))
(define/augment (on-close)
(let ([group (group:get-the-frame-group)])
(when (eq? this (send group get-open-here-frame))
(send group set-open-here-frame #f)))
(inner (void) on-close))
(define/override (on-activate on?)
(super on-activate on?)
(when on?
(send (group:get-the-frame-group) set-open-here-frame this)))
(inherit get-editor)
(define/public (get-open-here-editor) (get-editor))
(define/public (open-here filename)
(let* ([editor (get-open-here-editor)]
[okay-to-switch? (user-okays-switch? editor)])
(when okay-to-switch?
(when (is-a? editor text%)
(let* ([b (box #f)]
[filename (send editor get-filename b)])
(unless (unbox b)
(when filename
(handler:set-recent-position
filename
(send editor get-start-position)
(send editor get-end-position))))))
(send editor begin-edit-sequence)
(send editor lock #f)
(send editor load-file/gui-error filename)
(send editor end-edit-sequence)
(void))))
(inherit get-label)
(define/private (user-okays-switch? ed)
(or (not (send ed is-modified?))
(let ([answer
(gui-utils:unsaved-warning
(let ([fn (send ed get-filename)])
(if fn
(path->string fn)
(get-label)))
(string-constant switch-anyway)
#t)])
(case answer
[(continue)
#t]
[(save)
(send ed save-file/gui-error)]
[(cancel)
#f]))))
(super-new)))
(define text<%> (interface (-editor<%>)))
(define text-mixin
(mixin (-editor<%>) (text<%>)
@ -2738,10 +2616,9 @@
(define status-line% (status-line-mixin text-info%))
(define standard-menus% (standard-menus-mixin status-line%))
(define editor% (editor-mixin standard-menus%))
(define open-here% (open-here-mixin editor%))
(define -text% (text-mixin open-here%))
(define -text% (text-mixin editor%))
(define searchable% (searchable-text-mixin (searchable-mixin -text%)))
(define delegate% (delegate-mixin searchable%))
(define -pasteboard% (pasteboard-mixin open-here%))
(define -pasteboard% (pasteboard-mixin editor%))

View File

@ -162,19 +162,6 @@
(set-close-menu-item-state! a-frame #t))
frames))))
(field [open-here-frame #f])
(define/public (set-open-here-frame fr) (set! open-here-frame fr))
(define/public (get-open-here-frame)
(cond
[open-here-frame open-here-frame]
[else
(let ([candidates
(filter (λ (x) (is-a? (frame-frame x) frame:open-here<%>))
frames)])
(if (null? candidates)
#f
(frame-frame (car candidates))))]))
(define/public (get-mdi-parent)
(when (and (eq? (system-type) 'windows)
(preferences:get 'framework:windows-mdi)

View File

@ -101,14 +101,6 @@
(send already-open make-visible filename)
(send already-open show #t)
already-open]
[(and (preferences:get 'framework:open-here?)
(send (group:get-the-frame-group) get-open-here-frame))
=>
(λ (fr)
(add-to-recent filename)
(send fr open-here filename)
(send fr show #t)
fr)]
[else
(let ([handler (and (path? filename)
(find-format-handler filename))])
@ -228,11 +220,7 @@
[end (caddr recent-list-item)])
(cond
[(file-exists? filename)
(let ([fr (edit-file filename)])
(when (is-a? fr frame:open-here<%>)
(let ([ed (send fr get-open-here-editor)])
(when (equal? (send ed get-filename) filename)
(send ed set-position start end)))))]
(edit-file filename)]
[else
(preferences:set 'framework:recently-opened-files/pos
(remove* (list recent-list-item)
@ -355,8 +343,7 @@
(super-instantiate ()))))
(define (open-file [directory #f])
(let* ([parent (and (or (not (eq? 'macosx (system-type)))
(preferences:get 'framework:open-here?))
(let* ([parent (and (not (eq? 'macosx (system-type)))
(get-top-level-focus-window))]
[file
(parameterize ([finder:dialog-parent-parameter parent])

View File

@ -196,7 +196,6 @@
(λ (x) (or (eq? x 'age) (eq? x 'name))))
(preferences:set-default 'framework:recent-items-window-w 400 number?)
(preferences:set-default 'framework:recent-items-window-h 600 number?)
(preferences:set-default 'framework:open-here? #f boolean?)
(preferences:set-default 'framework:show-delegate? #f boolean?)
(preferences:set-default 'framework:windows-mdi #f boolean?)
(preferences:set-default 'framework:menu-bindings #t boolean?)

View File

@ -464,10 +464,6 @@ the state transitions / contracts are:
'framework:auto-set-wrap?
(string-constant wrap-words-in-editor-buffers)
values values)
(make-check editor-panel
'framework:open-here?
(string-constant reuse-existing-frames)
values values)
(make-check editor-panel
'framework:menu-bindings

View File

@ -262,7 +262,6 @@
status-line<%>
standard-menus<%>
editor<%>
open-here<%>
text<%>
pasteboard<%>
delegate<%>
@ -280,7 +279,6 @@
pasteboard-info%
standard-menus%
editor%
open-here%
text%
searchable%
delegate%
@ -293,7 +291,6 @@
status-line-mixin
standard-menus-mixin
editor-mixin
open-here-mixin
text-mixin
pasteboard-mixin
delegate-mixin

View File

@ -683,61 +683,6 @@
}
}
@definterface[frame:open-here<%> (frame:editor<%>)]{
Frames implementing this mixin can change the file they are displaying.
The frame is only re-used when the @racket['framework:open-here?] preference
is set (see @racket[preferences:get] and @racket[preferences:set] for details
on preferences).
The @racket[frame:open-here-mixin] implements this interface.
@defmethod*[(((get-open-here-editor) (is-a?/c editor<%>)))]{
When the user switches the visible file in this frame, the of this method
is the editor that gets switched.
By Default, returns the result of @method[frame:editor<%> get-editor].
}
@defmethod*[(((open-here (filename string)) void?))]{
Opens @racket[filename] in the current frame, possibly prompting the user
about saving a file (in which case the frame might not get switched).
}
}
@defmixin[frame:open-here-mixin (frame:editor<%>) (frame:open-here<%>)]{
Provides an implementation of @racket[frame:open-here<%>]
@defmethod*[#:mode override (((file-menu:new-on-demand (item (is-a?/c menu-item%))) void?))]{
Sets the label of @racket[item] to @racket["New..."] if the preference
@racket['framework:open-here?] is set.
}
@defmethod*[#:mode override (((file-menu:new-callback (item (is-a?/c menu-item%))
(evt (is-a?/c control-event%)))
void?))]{
When the preference @racket['framework:open-here?] preference is set, this
method prompts the user, asking if they would like to create a new frame,
or just clear out this one. If they clear it out and the file hasn't been
saved, they are asked about saving.
}
@defmethod*[#:mode override (((file-menu:open-on-demand (item (is-a?/c menu-item%))) void?))]{
Sets the label of @racket[item] to "Open Here..." if the preference
@racket['framework:open-here?] is set.
}
@defmethod*[#:mode augment (((on-close) void?))]{
Calls @method[group:% set-open-here-frame] with @racket[#f] if the result
of @method[group:% get-open-here-frame] is @racket[eq?] to @racket[this].
}
@defmethod*[#:mode override (((on-activate (on? boolean?)) void?))]{
When @racket[on?] is @racket[#t], calls @method[group:%
set-open-here-frame] with @racket[this].
}
}
@definterface[frame:text<%> (frame:editor<%>)]{
Frames matching this interface provide support for @racket[text%]s.
}
@ -995,10 +940,9 @@
@defclass[frame:status-line% (frame:status-line-mixin frame:text-info%) ()]{}
@defclass[frame:standard-menus% (frame:standard-menus-mixin frame:status-line%) ()]{}
@defclass[frame:editor% (frame:editor-mixin frame:standard-menus%) ()]{}
@defclass[frame:open-here% (frame:open-here-mixin frame:editor%) ()]{}
@defclass[frame:text% (frame:text-mixin frame:open-here%) ()]{}
@defclass[frame:text% (frame:text-mixin frame:editor%) ()]{}
@defclass[frame:searchable% (frame:searchable-text-mixin (frame:searchable-mixin frame:text%)) ()]{}
@defclass[frame:delegate% (frame:delegate-mixin frame:searchable%) ()]{}
@defclass[frame:pasteboard% (frame:pasteboard-mixin frame:open-here%) ()]{}
@defclass[frame:pasteboard% (frame:pasteboard-mixin frame:editor%) ()]{}
@(include-previously-extracted "main-extracts.rkt" #rx"^frame:")

View File

@ -11,15 +11,6 @@
constructed with @racket[frame:basic-mixin] adds itself to the result of
@racket[group:get-the-frame-group].
@defmethod*[(((set-open-here-frame (frame (is-a?/c frame:editor%))) void?))]{
Sets the frame to load new files into. See also
@racket[frame:open-here<%>].
}
@defmethod*[(((get-open-here-frame) (or/c false/c (is-a?/c frame:editor<%>))))]{
Returns the currently saved frame to load new files into.
}
@defmethod*[(((get-mdi-parent) (or/c false/c (is-a?/c frame%))))]{
The result of this method must be used as the parent frame for each frame
in the group.

View File

@ -556,7 +556,6 @@ please adhere to these guidelines:
(open-info "Åbn en fil fra disk")
(open-menu-item "&Åbn...")
(open-here-menu-item "&Åbn her...")
(open-recent-info "En liste af filer brugt for nylig")
(open-recent-menu-item "Åbn gammel")

View File

@ -353,7 +353,6 @@
(open-info "Open bestand van schijf")
(open-menu-item "&Open...")
(open-here-menu-item "&Open Hier...")
(open-recent-info "Onlangs geopende bestanden")
(open-recent-menu-item "Open opnieuw")

View File

@ -667,7 +667,6 @@ please adhere to these guidelines:
(open-info "Open a file from disk")
(open-menu-item "&Open...")
(open-here-menu-item "&Open Here...")
(open-recent-info "A list of the recently opened files")
(open-recent-menu-item "Open Recen&t")

View File

@ -628,7 +628,6 @@
(open-info "Ouvrir un fichier à partir du disque dur.")
(open-menu-item "&Ouvrir")
(open-here-menu-item "&Ouvrir ici...")
(open-recent-info "Une liste des fichiers ouverts récemment.")
(open-recent-menu-item "Ouvrir récen&t")

View File

@ -556,7 +556,6 @@
(open-info "Datei öffnen")
(open-menu-item "&Öffnen...")
(open-here-menu-item "Hier &öffnen...")
(open-recent-info "Liste kürzlich bearbeiteter Dateien")
(open-recent-menu-item "Noch einmal öffnen")

View File

@ -604,7 +604,6 @@ please adhere to these guidelines:
(open-info "ディスクからファイルを開きます")
(open-menu-item "開く(&O)...")
(open-here-menu-item "ここに開く(&O)...")
(open-recent-info "最近開いたファイルの一覧を表示します")
(open-recent-menu-item "最近開いたファイル")

View File

@ -534,7 +534,6 @@
(open-info "디스크에서 파일 가져와서 열기")
(open-menu-item "열기 (&O)")
(open-here-menu-item "여기에 열기 (&O)")
(open-recent-info "최근 열어본 파일 목록")
(open-recent-menu-item "최근 파일 열기 (&T)")

View File

@ -557,7 +557,6 @@ please adhere to these guidelines:
(open-info "Abrir ficheiro do disco")
(open-menu-item "&Abrir...")
(open-here-menu-item "&Abrir aqui...")
(open-recent-info "A lista dos ficheiros abertos mais recentes")
(open-recent-menu-item "Abrir Recente")

View File

@ -609,7 +609,6 @@ please adhere to these guidelines:
(open-info "Открыть файл с диска")
(open-menu-item "&Открыть...")
(open-here-menu-item "&Открыть здесь...")
(open-recent-info "Список последних открытых файлов")
(open-recent-menu-item "Открыть &последние")

View File

@ -521,7 +521,6 @@
(open-info "打开现有文件")
(open-menu-item "打开(&O)...")
(open-here-menu-item "从这里打开(&O)...")
(open-recent-info "最近使用过文件的列表")
(open-recent-menu-item "最近使用过的文件(&T)")

View File

@ -448,7 +448,6 @@
(open-info "Abre un nuevo archivo del disco")
(open-menu-item "&Abrir...")
(open-here-menu-item "&Abrir aquí...")
(open-recent-info "Una lista de archivos abiertos recientemente")
(open-recent-menu-item "Abrir reciente")

View File

@ -520,7 +520,6 @@
(open-info "打开现有文件")
(open-menu-item "打开(&O)...")
(open-here-menu-item "从这里打开(&O)...")
(open-recent-info "最近使用过文件的列表")
(open-recent-menu-item "最近使用过的文件(&T)")

View File

@ -609,7 +609,6 @@ please adhere to these guidelines:
(open-info "Відкрити файл з диску")
(open-menu-item "&Відкрити...")
(open-here-menu-item "&Відкрити тут...")
(open-recent-info "Список останніх відкритих файлів")
(open-recent-menu-item "Відкрити о&станні")

View File

@ -12,6 +12,9 @@
. added online expansion and check syntax
. removed the "open here" functionality (both from
the DrRacket app and from the framework library)
. 2htdp/image:
- shrunk the size of saved files that contain 2htdp/image bitmaps
(you can get these by copying and pasting from the REPL; using