[comp.sys.mac.programmer] Shutdown sequence question

rgm@sandstorm.Berkeley.EDU (Robert Menke) (12/07/89)

This is beginning to bother me.  How does the Finder (under
MultiFinder) send messages to each of the open applications to close
when the user selects "Shut Down" from the "Special" menu?

Obviously it is not a patch to the _Shutdown macro (or is it? I'm not
sure how patches are handled under MultiFinder) nor does it seem to be
procedures installed via ShutDwnInstall (or do procedures installed
only execute if the application containing them is the active one?
That would seem silly).

This is bothersome to me because I use MPW 2.0.2 as a CLI more often
than I use the finder, and it's irritating to have to flip out to the
finder to quit (even MPW's "shutdown" command fails to notify
applications).

If this has been covered, send answers via e-mail, etc, etc.


"It is a pity that you Autobots die so	|  Robert Menke
easily..."				|    rgm@OCF.berkeley.edu
			-Galvatron	|    Robert.Menke@bmug.fidonet.org
               TEAM CS -- Making Tomorrow's Mistakes Today!

vallon@sbmiclr.CS.SunySB.EDU (Justin Vallon) (12/08/89)

In article <1989Dec7.083540.3798@agate.berkeley.edu>,
rgm@sandstorm.Berkeley.EDU (Robert Menke) writes:
> This is beginning to bother me.  How does the Finder (under
> MultiFinder) send messages to each of the open applications to close
> when the user selects "Shut Down" from the "Special" menu?
...
> [MPW's "shutdown" command fails to notify applications]

Shut Down from the Finder does not need to be patched.  Finder (when running
in MultiFinder mode) "knows" that it has to notify open applications about
a pending restart/shutdown.  What the Finder does is it looks for the "Quit"
item in the "File" menu of all open applications and calls it (it can do
that, you know... it's MultiFinder).  [I also remember that the defaults for
these strings can be overrided by some resource]  When all open applications
are closed (you can cancel a shutdown/restart by clicking on the Cancel
button in the "Save changes to ^0?" alert), the Finder then invokes the
Restart/Shutdown trap.  (All from memory, but I've heard this here before).

So, how to fix it?  If you have a Macro program (MacroMaker :-(, QuicKeys,
etc), create a Macro that clicks on the trash-can (to switch to the Finder
layer), and then calls menu item "Special"/"Shutdown".  The only problem with
the macro is that you can't hide the trash-can, which frequently happens.

I can't think of anything else off the top of my head.  Maybe somebody else
can come up with a solution.  Maybe a Switch-To-Finder FKEY?

> "It is a pity that you Autobots die so	|  Robert Menke
> easily..."				|    rgm@OCF.berkeley.edu
> 			-Galvatron	|    Robert.Menke@bmug.fidonet.org
>                TEAM CS -- Making Tomorrow's Mistakes Today!

-Justin
vallon@sbcs.sunysb.edu

nf0i+@andrew.cmu.edu (Norman William Franke, III) (12/08/89)

>So, how to fix it?  If you have a Macro program (MacroMaker :-(, QuicKeys,
>etc), create a Macro that clicks on the trash-can (to switch to the Finder
>layer), and then calls menu item "Special"/"Shutdown".  The only problem with
>the macro is that you can't hide the trash-can, which frequently happens.
> 
>I can't think of anything else off the top of my head.  Maybe somebody else
>can come up with a solution.  Maybe a Switch-To-Finder FKEY?

One could purchase QuickKeys, and make a macro which will shutdown. This
macro then automatically switches to the finder, and selects it's
stutdown. Sounds complicated? It does it all by it self, just select
"Define-Special-Shutdown", I believe, from the menu...

-Norman Franke
nf0i+@andrew.cmu.edu

(I have nothing to do with CE Software, BTW, just passing along info!)

d88-jwa@nada.kth.se (Jon Watte) (12/09/89)

In article <4193@sbcs.sunysb.edu> vallon@sbmiclr.CS.SunySB.EDU (Justin Vallon) writes:
>In article <1989Dec7.083540.3798@agate.berkeley.edu>,

>Shut Down from the Finder does not need to be patched.  Finder (when running
>in MultiFinder mode) "knows" that it has to notify open applications about
>a pending restart/shutdown.  What the Finder does is it looks for the "Quit"
>item in the "File" menu of all open applications and calls it (it can do
>that, you know... it's MultiFinder).  [I also remember that the defaults for
>these strings can be overrided by some resource]  When all open applications

Yes, you can. I frequently have to do this because a) the program didn't
have this resource or b) the resource was not translated to swedish
although the menus were... :-(

>So, how to fix it?  If you have a Macro program (MacroMaker :-(, QuicKeys,
>etc), create a Macro that clicks on the trash-can (to switch to the Finder

Why not choose "Finder" from the Apple menu ? QuickKeys certainly lets you
do this, and I believe other do as well.

You could have an FKEY doing OpenDeskAcc("\PFinder") but then you'd
be looking for trouble !

-- 
   --  Stay alert !  -  Trust noone !  -  Keep your laser handy !  ---
            h+@nada.kth.se  ==  h+@proxxi.se  ==  Jon Watte
                   longer .sig available on request

vallon@sboslab2.cs.sunysb.edu (Justin Vallon) (12/09/89)

In article <2500@draken.nada.kth.se>, d88-jwa@nada.kth.se (Jon Watte) writes:
> In article <4193@sbcs.sunysb.edu> vallon@sbmiclr.CS.SunySB.EDU (Justin
Vallon) writes:
> >So, how to fix it?  If you have a Macro program (MacroMaker :-(, QuicKeys,
> >etc), create a Macro that clicks on the trash-can (to switch to the Finder
> 
> Why not choose "Finder" from the Apple menu ? QuickKeys certainly lets you
> do this, and I believe other do as well.

Now, why didn't I think of that?  Oh, wait a minute.  My brain hasn't been
on for a week.  <Click>  That's better.

>    --  Stay alert !  -  Trust noone !  -  Keep your laser handy !  ---
>             h+@nada.kth.se  ==  h+@proxxi.se  ==  Jon Watte
>                    longer .sig available on request

-Justin
vallon@sbcs.sunysb.edu

tim@hoptoad.uucp (Tim Maroney) (12/10/89)

In article <1989Dec7.083540.3798@agate.berkeley.edu> rgm@OCF.Berkeley.EDU
(Robert Menke) writes:
>This is beginning to bother me.  How does the Finder (under
>MultiFinder) send messages to each of the open applications to close
>when the user selects "Shut Down" from the "Special" menu?

By magic.  It goes through the MultiFinder list of applications,
searches each one for a quit command in the file menu, posts a fake
mouse-down event in the menu bar, and patches MenuSelect to return the
number of the required menu item.  It then waits for the application
quit, including any necessary save dialogs.  You can't do this and it
would be unwise to try.

>Obviously it is not a patch to the _Shutdown macro (or is it? I'm not
>sure how patches are handled under MultiFinder) nor does it seem to be
>procedures installed via ShutDwnInstall (or do procedures installed
>only execute if the application containing them is the active one?
>That would seem silly).

Nope, the Shutdown Manager is not involved.  If you call Shutdown from
your own program, it's tough cookies for any other applications that
may be running at the time.  The Finder does it strictly in response to
receiving the Restart and Shut Down menu commands.  Hopefully, the
Shutdown manager will do this in System 7.0, but I wouldn't hold my
breath.  (Since you'll be able to give a Finder menu command from other
applications then anyway, it's not really mandatory.)

>This is bothersome to me because I use MPW 2.0.2 as a CLI more often
>than I use the finder, and it's irritating to have to flip out to the
>finder to quit (even MPW's "shutdown" command fails to notify
>applications).

Yep.  It's a pain.  No good way around it, though.
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"There are no Famous People on the net.  Only some of us with bigger mouths
 than others."  -- Dan'l Danehy-Oakes, The Roach