Main Page | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages

DownAndOutController Class Reference

#import <DownAndOutController.h>

Collaboration diagram for DownAndOutController:

Collaboration graph
[legend]
List of all members.

Detailed Description

Core actor for the DownAndOut screensaver/utility.

Definition at line 60 of file DownAndOutController.h.

Public Member Functions

(id) - initAsPreview:forView:
 Designated initializer.
(int) - secondsBeforeLogout
 Getter for the starting value of the countdown clock, in seconds.
(void) - setSecondsBeforeLogout:
 Setter for the starting value of the countdown clock, in seconds.
(BOOL) - shouldMove
 Whether the screen saver content should move around the screen.
(NSImage *) - addedImage
 Getter for the image to be shown in addition to the screen saver content.
(void) - setAddedImage:
 Setter for the image to be shown in addition to the dynamic content.
(NSString *) - messageText
 Accessor for the message text template.
(NSString *) - messageTextForSeconds:
 Message text with % tokens substituted.
(void) - setMessageText:
 Setter for the message text template.
(NSPanel *) - panel
 Accessor to the configuration panel.
(void) - quitApplications
 Perform a gentle (AppleScript) quit on nonexempt applications.
(void) - killApplications
 Perform a brute-force (kill-SIGTERM) quit on nonexempt applications.
(NSString *) - nameOfThisApplication
 The name of the frontmost application.
(void) - makeTouchFile
 Write list of quit and killed applications to a file in /tmp.
(void) - logOut
 Log the current user out.
IBActions
(IBAction) - endButton:
 Action method for the OK and Cancel buttons.
(IBAction) - stepper:
 Action method for the time-to-logout stepper arrows.
(IBAction) - timeText:
 Action method for the time-till-logout field.
(IBAction) - moveSelected:
 Action method for the move-content radio buttons.
(IBAction) - imageAction:
 Action method for image well and related buttons (Set and Clear).
(IBAction) - restoreDefaults:
 Restores the default configuration by stuffing the panel with the default values.
(IBAction) - sliderAction:
 Action method responding to changes in the size-of-content slider.

Protected Attributes

DownAndOutViewview
 The screen-saver view itself.
Configuration Panel
IBOutlet NSButton * cancelButton
 Cancel button.
IBOutlet NSButton * okButton
 OK button.
IBOutlet NSButton * revertButton
 Restore Defaults button.
IBOutlet NSPanel * panel
 Configuration panel.
IBOutlet NSTextField * timeField
 Time-to-logout field.
IBOutlet NSStepper * timeStepper
 Stepper next to Time-to-logout field.
IBOutlet NSMatrix * movementMatrix
 Radio buttons, whether to move the content.
IBOutlet NSImageView * imageWell
 Image well.
IBOutlet NSButton * imageSet
 Set button for image.
IBOutlet NSButton * imageClear
 Clear button for image.
IBOutlet NSTextView * messageField
 Editor for message text.
IBOutlet NSSlider * sizeSlider
 Slider to set size of content.
Model.
When running the screen saver, the controller loads the model (when to shut down, what to say, how to display) from the preferences and keeps it in its own instance variables.

int secondsBeforeLogout
 Countdown, seconds till shutdown.
BOOL shouldMove
 Whether the content moves on the screen.
NSImage * addedImage
 Image to supplement the content.
NSString * messageText
 Template for the content text.


Member Function Documentation

- (NSImage *) addedImage  
 

Getter for the image to be shown in addition to the screen saver content.

Return values:
NSImage direct access to the addedImage instance variable.

- (IBAction) endButton: (id)  sender  
 

Action method for the OK and Cancel buttons.

Dismisses the configuration panel, and if the sender is the OK button, harvests the UI into the DAPreferences system.

Parameters:
sender the sender.

- (IBAction) imageAction: (id)  sender  
 

Action method for image well and related buttons (Set and Clear).

Surprisingly, none of these results in sending setAddedImage:, which is left till endButton: time.

Sets the Clear button according to whether an image is left in the well. Additionally,

  • If the sender is the clear button, the well is emptied.
  • If the sender is the set button, the well is filled with the user's selection in an NSOpenPanel.
  • If the sender is the well, nothing else happens.
    Parameters:
    sender the sender.

- (id) initAsPreview: (BOOL)  inIsPreview
forView: (DownAndOutView *)  view
 
 

Designated initializer.

The DownAndOutView, as the known entry to the screen-saver bundle, will allocate and initialize the DownAndOutController from its initializer. The view will know whether it is being run as a preview.

Parameters:
[in] inIsPreview whether the view was run as a preview.
[in] view the associated DownAndOutView.
Return values:
self always.

- (void) killApplications  
 

Perform a brute-force (kill-SIGTERM) quit on nonexempt applications.

In practice, only Finder is exempt.

See also:
DAAppication::kill:

Referenced by DownAndOutView::animateOneFrame.

- (void) logOut  
 

Log the current user out.

This method sends the Apple Event aevtrlgo to the loginwindow process. This is the non-interactive logout event. After all user processes have been quit, there is no reason to expect this to fail.

If an error arises from sending the Apple Event, the error dictionary is dumped to the console as a log entry with the prefix "Error Dict =".

Referenced by DownAndOutView::animateOneFrame.

- (void) makeTouchFile  
 

Write list of quit and killed applications to a file in /tmp.

This method runs through the quit-applications and killed-applications lists of DAApplication, writing the names in the format

	Quit: | Killed:     applicationName
one per line to a file at /tmp/userName.DownAndOut, where userName is the UNIX user name of the current user.

DownAndOutView sends this message immediately before sending logOut to the controller.

Referenced by DownAndOutView::animateOneFrame.

- (NSString *) messageText  
 

Accessor for the message text template.

Return values:
NSString the receiver's message-text template text, unexpanded.
See also:
messageText

- (NSString *) messageTextForSeconds: (int)  seconds  
 

Message text with % tokens substituted.

The messageText property is copied into an NSMutableString, and

  • All instances of %u are replaced with the current user's UNIX user name.
  • All instances of %n are replaced with the current user's proper name.
  • All instances of %t are replaced with seconds rendered in minutes:seconds format.
  • All instances of %s are replaced with seconds as an integer.

Parameters:
seconds integer, the number of seconds to show for the countdown value.
Return values:
NSString the message text template formatted as described.

Referenced by DownAndOutView::fillTextImageWithSeconds:.

- (IBAction) moveSelected: (id)  sender  
 

Action method for the move-content radio buttons.

This is a no-op; nothing is done with the state transition. The final state is captured when the OK button is pressed.

Parameters:
sender the sender.

- (NSString *) nameOfThisApplication  
 

The name of the frontmost application.

This seeks the NSApplicationName key of the -[NSWorkspace activeApplication]. This method doesn't seem to be used anywhere.

Return values:
NSString the name of the frontmost application.

- (NSPanel *) panel  
 

Accessor to the configuration panel.

This is set when the DownAndOut[tm].nib is loaded.

Return values:
NSPanel the receiver's configuration panel instance.

- (void) quitApplications  
 

Perform a gentle (AppleScript) quit on nonexempt applications.

Executes a quit-without-saving script on every application that is currently running and is not exempt from quitting. In practice, only Finder is exempt.

See also:
- quitWithoutSaving (DAApplication)

Referenced by DownAndOutView::animateOneFrame.

- (IBAction) restoreDefaults: (id)  sender  
 

Restores the default configuration by stuffing the panel with the default values.

Parameters:
sender the sender.
Bug:
The right way to reset the configuration UI would be to refer to the same dictionary used to initialize the preference file and load the widgets from that.

- (int) secondsBeforeLogout  
 

Getter for the starting value of the countdown clock, in seconds.

Return values:
int initial seconds till DownAndOut[tm] starts quitting applications.

- (void) setAddedImage: (NSImage *)  anImage  
 

Setter for the image to be shown in addition to the dynamic content.

Conforms the image well and the activation of the imageClear UI element.

Parameters:
anImage NSImage, the image to set (retained), or nil to clear.

- (void) setMessageText: (NSString *)  newText  
 

Setter for the message text template.

Updates the message-text field.

Parameters:
newText NSString, the text to replace the current message text template.
See also:
messageText.

- (void) setSecondsBeforeLogout: (int)  seconds  
 

Setter for the starting value of the countdown clock, in seconds.

The timeField and timeStepper display elements are adjusted to conform.

Parameters:
seconds the initial values of the countdown clock.

- (BOOL) shouldMove  
 

Whether the screen saver content should move around the screen.

Defaults to true, and set by the UI through endButton:, or through the saved preferences.

Return values:
BOOL whether content should move.

- (IBAction) sliderAction: (id)  sender  
 

Action method responding to changes in the size-of-content slider.

This is a no-op; the final value is collected from the UI at endButton: time.

Parameters:
sender the sender.

- (IBAction) stepper: (id)  sender  
 

Action method for the time-to-logout stepper arrows.

Retrieves the integer value of the sender, and performs setSecondsBeforeLogout: to make sure the time-to-logout field is synchronized.

Parameters:
sender the sender.

- (IBAction) timeText: (id)  sender  
 

Action method for the time-till-logout field.

Parses the contents of the field as decimal seconds, or as minutes and seconds delimited by [ .:]. The stepper is made to conform, and the field is formatted as minutes:seconds.

Parameters:
sender the sender.


The documentation for this class was generated from the following file:
Generated on Wed Jan 25 12:04:27 2006 for DownAndOut by  doxygen 1.4.4