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.

original commit: 048fa1d7b8b5e17ac58181b068d779806bd5c59a
This commit is contained in:
Robby Findler 2011-09-21 22:50:24 -05:00
parent 4e3cda33e3
commit dfb6f53f0e
9 changed files with 7 additions and 236 deletions

View File

@ -838,14 +838,7 @@
((filename) ((filename)
((make-default ((make-default
(λ () ((handler:current-create-new-window) filename))))) (λ () ((handler:current-create-new-window) filename)))))
@{This function creates a frame or re-uses an existing frame to edit a file. @{This function invokes the appropriate format handler to open the file (see
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
@racket[handler:insert-format-handler]). @racket[handler:insert-format-handler]).
@itemize[ @itemize[

View File

@ -1453,128 +1453,6 @@
;; it might not yet be implemented ;; it might not yet be implemented
(send canvas focus))))) (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<%> (interface (-editor<%>)))
(define text-mixin (define text-mixin
(mixin (-editor<%>) (text<%>) (mixin (-editor<%>) (text<%>)
@ -2738,10 +2616,9 @@
(define status-line% (status-line-mixin text-info%)) (define status-line% (status-line-mixin text-info%))
(define standard-menus% (standard-menus-mixin status-line%)) (define standard-menus% (standard-menus-mixin status-line%))
(define editor% (editor-mixin standard-menus%)) (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 searchable% (searchable-text-mixin (searchable-mixin -text%)))
(define delegate% (delegate-mixin searchable%)) (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)) (set-close-menu-item-state! a-frame #t))
frames)))) 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) (define/public (get-mdi-parent)
(when (and (eq? (system-type) 'windows) (when (and (eq? (system-type) 'windows)
(preferences:get 'framework:windows-mdi) (preferences:get 'framework:windows-mdi)

View File

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

View File

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

View File

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

View File

@ -262,7 +262,6 @@
status-line<%> status-line<%>
standard-menus<%> standard-menus<%>
editor<%> editor<%>
open-here<%>
text<%> text<%>
pasteboard<%> pasteboard<%>
delegate<%> delegate<%>
@ -280,7 +279,6 @@
pasteboard-info% pasteboard-info%
standard-menus% standard-menus%
editor% editor%
open-here%
text% text%
searchable% searchable%
delegate% delegate%
@ -293,7 +291,6 @@
status-line-mixin status-line-mixin
standard-menus-mixin standard-menus-mixin
editor-mixin editor-mixin
open-here-mixin
text-mixin text-mixin
pasteboard-mixin pasteboard-mixin
delegate-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<%>)]{ @definterface[frame:text<%> (frame:editor<%>)]{
Frames matching this interface provide support for @racket[text%]s. 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:status-line% (frame:status-line-mixin frame:text-info%) ()]{}
@defclass[frame:standard-menus% (frame:standard-menus-mixin frame:status-line%) ()]{} @defclass[frame:standard-menus% (frame:standard-menus-mixin frame:status-line%) ()]{}
@defclass[frame:editor% (frame:editor-mixin frame:standard-menus%) ()]{} @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:editor%) ()]{}
@defclass[frame:text% (frame:text-mixin frame:open-here%) ()]{}
@defclass[frame:searchable% (frame:searchable-text-mixin (frame:searchable-mixin frame:text%)) ()]{} @defclass[frame:searchable% (frame:searchable-text-mixin (frame:searchable-mixin frame:text%)) ()]{}
@defclass[frame:delegate% (frame:delegate-mixin frame:searchable%) ()]{} @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:") @(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 constructed with @racket[frame:basic-mixin] adds itself to the result of
@racket[group:get-the-frame-group]. @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%))))]{ @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 The result of this method must be used as the parent frame for each frame
in the group. in the group.