[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Revert menu-item not enable
- To: andre_koehorst@riks.nl, "Mark A. Tapia" <markt@dgp.toronto.edu>
- Subject: Re: Revert menu-item not enable
- From: bill@cambridge.apple.com (Bill St. Clair)
- Date: Mon, 2 Aug 1993 16:09:52 -0500
- Cc: info-mcl@cambridge.apple.com
At 12:18 PM 8/2/93 -0400, Mark A. Tapia wrote:
>On Mon Aug 2, Andre Koehorst writes:
> REGARDING Revert menu-item not enabled
> If we define a window-revert method for a window class, the
> standard menu item "Revert" will not be enabled (when an instances
> is made active) if we've also defined a window-needs-saving-p
> method for that class.
>
>...
> Test machines: FX, 16-32 meg sys 7.1. (more info when necessary)
> Is this a bug?
>... code omitted
>
>I've tried your example under Common Lisp Version 2.0p2
>and have been unable to duplicate the problem.
>1. the Save menu item of the *file-menu* is enabled for both windows.
>2. The Revert menu item of the *file-menu* is enabled for the window
> (test2) with the window-revert method and disabled for
> the window without a window-revert method.
>Perhaps you're running a different version or you've changed
>the behavior of the *file-menu* or the Revert menu item.
>
>mark
>
>The standard ccl::update-function for the *file-menu* is nil.
>
>The standard ccl::update-function for the revert menu item is the
> CCL::REVERT-MENU-ITEM-UPDATE function
>The function executes the following steps.
>1. If there is a front window continue
> otherwise disable the revert item and return
>2. If a window-revert method exists for the front window continue,
> otherwise disable the revert item and return
>3. If a window-needs-saving-p method exists for the front window continue,
> otherwise disable the revert item
>4. When a window-filename exists for the front window, then execute it.
>5. Invoke the window-needs-saving-p method.
> If it returns t, then enable the revert menu item
> otherwise disable the revert menu item.
I WAS able to duplicate the problem. The "Revert" menu item is not
enabled for the window with the WINDOW-NEEDS-SAVING-P method. The
MCL documentation says nothing about this, but the CCL::REVERT-MENU-ITEM-UPDATE
function explains why it happens:
(defun revert-menu-item-update (item &aux (wob (front-window)))
(if (and wob
(method-exists-p 'window-revert wob)
(or (not (method-exists-p 'window-needs-saving-p wob))
(and (or (not (method-exists-p 'window-filename wob))
(window-filename wob))
(window-needs-saving-p wob))))
(menu-item-enable item)
(menu-item-disable item)))
The problem with this code is that there is a WINDOW-FILENAME method specialized
on the STREAM class, which returns NIL by default. Hence, the easiest way
to make the revert menu update is to define a WINDOW-FILENAME method that returns
some non-NIL value:
(defmethod window-filename ((w testwin))
"Unknown")
The proper fix to this would involve creating more of a protocol for enabling the
"Revert" menu item. For Fred windows, it should really always be enabled, since
the file that a Fred window is editing can be modified at any time by another
application (or even another user); Fred, like EMACS, does not lock files while it
edits them. Most conventional Mac applications do lock the file in which a document
lives while it is being displayed in a window. Hence, the current behavior is
probably right for them. Sounds like REVERT-MENU-ITEM-UPDATE should call
WINDOW-CAN-DO-OPERATION. This would give you complete control over this menu's
behavior for your windows. I'll put this on my list of desireable new features
for MCL.