DockyardMenuExtra

Dockyard > Objective-C Classes > DockyardMenuExtra

DockyardMenuExtra

Class Description

Central class of the Dockyard menu extra. This class handles the menu and commands, as well as functioning as a Controller in the MVC scheme (although Dockyard usually implements two levels of Controllers), between the Dockyard library (Model) and the menus presented to the user (View). Actions are handled by their respective controllers, but most presentation configuration is done here.

By Belkadan Software

Methods

- changeDockCommand:

- dealloc

- iconForDockItemPath:type:

- initWithBundle:

- labelForDockItemData:type:

- menuForDockNamed:

- menuItemWithDockItemData:type:

- openFile:

- pathForDockItemData:type:

- preferences

- shouldUseBWIconChanged:

- showAbout:

- showDelete:

- showNew:

- showRename:

- showReorder:

- typeForDockItemData:rawType:

Method Detail

changeDockCommand:

- (void)changeDockCommand:(NSMenuItem *)menuItem

Switches to the dock with the same name as the represented object of menuItem (stored on creation). This function just calls changeDock: on `DockyardPreferences`

See also: DockyardPreferences.changeDock:

dealloc

- (void)dealloc

Releases the menu, view, lists of docks, and strings that were allocated. Then calls [super dealloc].

iconForDockItemPath:type:

- (NSImage *)iconForDockItemPath:(NSString *)path type:(enum DockyardItemType)itemType

Tries to locate an icon in four ways: First: Looks to see if there is a path, and assigns a default unknown icon if there isn't. Second: Checks the type of the path, and assigns a default icon for URLs. Third: Assumes the path is a local file, and looks for its icon on the filesystem. Fourth: Gives up and assigns a default unknown icon.

initWithBundle:

- (id)initWithBundle:(NSBundle *)bundle

Creates basically the entire menu extra. First, the backend (`DockyardPreferences`) is set up, and checked to see whether the black-and-white icon should be used. Next, the menu extra's view is set up and the Dockyard icon is set. After that, the menu commands are added, followed by a separator. Finally, the docks themselves are added, all of which trigger a switch when chosen.

labelForDockItemData:type:

- (NSString *)labelForDockItemData:(NSDictionary *)itemData type:(enum DockyardItemType)itemType

Finds a label for the specified data by searching the item data for the value of "file-label" or "label". If neither is found, the name of the program or file is returned.

menuForDockNamed:

- (NSMenu *)menuForDockNamed:(NSString *)dockName

Creates a menu based on the name of a dock. This is accomplished by searching the data for that particular dock for information about the items contained within it. The resulting menu has the following form, including images for both applications and documents:

     DOCK NAME | Switch to DOCK NAME
               | -------------------
               | [_] First App
               | [_] Second App
               | -------------------
               | [-] First Document

menuItemWithDockItemData:type:

- (NSMenuItem *)menuItemWithDockItemData:(NSDictionary *)itemData type:(enum DockyardItemType)itemType

This method takes the data of an item in a dock and creates a menu from it. The two attributes focused on are the label and icon of the item, as well as the path of the item (so it can be opened later) but these are taken from labelForDockItemData:, iconForDockItemPath:, and pathForDockItemData:.

openFile:

- (void)openFile:(NSMenuItem *)sender

Opens the file with the path specified by the menu item. The path is stored in the menu item's `representedObject`

pathForDockItemData:type:

- (NSString *)pathForDockItemData:(NSDictionary *)itemData type:(enum DockyardItemType)itemType

Finds the path of the given data by first looking for a file path, then URL data.

preferences

- (DockyardPreferences *)preferences

Returns the instance of `DockyardPreferences` shared throughout the menu extra. Mainly used for KVC purposes and access by the other controllers.

shouldUseBWIconChanged:

- (void)shouldUseBWIconChanged:(NSNotification *)note

Response to a DockyardDefaultsChangedNotification when the key is `@"MenuExtra:shouldUseBWIcon"`. This method should never be directly invoked.

showAbout:

- (void)showAbout:(NSMenuItem *)menuItem

Displays Dockyard's About panel, loading the required nib file if necessary. The about panel also contains check boxes that toggle Dashboard switching and the black-and-white icon on and off.

showDelete:

- (void)showDelete:(NSMenuItem *)menuItem

Displays the panel used to delete docks, loading the required nib file if necessary. If there is only one dock, it beeps instead.

showNew:

- (void)showNew:(NSMenuItem *)menuItem

Displays the panel used to create new docks, loading the required nib file if necessary.

showRename:

- (void)showRename:(NSMenuItem *)menuItem

Displays the panel used to rename a dock, loading the required nib file if necessary.

showReorder:

- (void)showReorder:(NSMenuItem *)menuItem

Displays the panel used to reorder docks, loading the required nib file if necessary. If there is only one dock, it beeps instead.

typeForDockItemData:rawType:

- (enum DockyardItemType)typeForDockItemData:(NSDictionary *)itemData rawType:(NSString *)rawType

Returns the item type for the given data, where `rawType` is in the form of a @"tile-type" string from the defaults domain com.apple.dock.

This page was generated with DocYouMeant, a program created by Belkadan Software