#define UPDATE_UI_SECONDS 1.0
-#define DOCK_SEEDING_TAG 101
-#define DOCK_DOWNLOADING_TAG 102
-
#define TRANSFER_PLIST @"/Library/Application Support/Transmission/Transfers.plist"
#define WEBSITE_URL @"http://www.transmissionbt.com/"
- (NSMenu *) applicationDockMenu: (NSApplication *) sender
{
NSInteger seeding = 0, downloading = 0;
- for (Torrent * torrent in fTorrents)
+ if (!fQuitting)
{
- if ([torrent isSeeding])
- seeding++;
- else if ([torrent isActive])
- downloading++;
- else;
+ for (Torrent * torrent in fTorrents)
+ {
+ if ([torrent isSeeding])
+ seeding++;
+ else if ([torrent isActive])
+ downloading++;
+ else;
+ }
}
- NSMenuItem * seedingItem = [fDockMenu itemWithTag: DOCK_SEEDING_TAG],
- * downloadingItem = [fDockMenu itemWithTag: DOCK_DOWNLOADING_TAG];
-
- BOOL hasSeparator = seedingItem || downloadingItem;
+ NSMenu * menu = [[NSMenu alloc] init];
if (seeding > 0)
{
NSString * title = [NSString stringWithFormat: NSLocalizedString(@"%d Seeding", "Dock item - Seeding"), seeding];
- if (!seedingItem)
- {
- seedingItem = [[[NSMenuItem alloc] initWithTitle: title action: nil keyEquivalent: @""] autorelease];
- [seedingItem setTag: DOCK_SEEDING_TAG];
- [fDockMenu insertItem: seedingItem atIndex: 0];
- }
- else
- [seedingItem setTitle: title];
- }
- else
- {
- if (seedingItem)
- [fDockMenu removeItem: seedingItem];
+ [menu addItemWithTitle: title action: nil keyEquivalent: @""];
}
if (downloading > 0)
{
NSString * title = [NSString stringWithFormat: NSLocalizedString(@"%d Downloading", "Dock item - Downloading"), downloading];
- if (!downloadingItem)
- {
- downloadingItem = [[[NSMenuItem alloc] initWithTitle: title action: nil keyEquivalent: @""] autorelease];
- [downloadingItem setTag: DOCK_DOWNLOADING_TAG];
- [fDockMenu insertItem: downloadingItem atIndex: seeding > 0 ? 1 : 0];
- }
- else
- [downloadingItem setTitle: title];
- }
- else
- {
- if (downloadingItem)
- [fDockMenu removeItem: downloadingItem];
+ [menu addItemWithTitle: title action: nil keyEquivalent: @""];
}
if (seeding > 0 || downloading > 0)
- {
- if (!hasSeparator)
- [fDockMenu insertItem: [NSMenuItem separatorItem] atIndex: (seeding > 0 && downloading > 0) ? 2 : 1];
- }
- else
- {
- if (hasSeparator)
- [fDockMenu removeItemAtIndex: 0];
- }
+ [menu addItem: [NSMenuItem separatorItem]];
+
+ [menu addItemWithTitle: NSLocalizedString(@"Pause All", "Dock item") action: @selector(stopAllTorrents:) keyEquivalent: @""];
+ [menu addItemWithTitle: NSLocalizedString(@"Resume All", "Dock item") action: @selector(resumeAllTorrents:) keyEquivalent: @""];
+ [menu addItem: [NSMenuItem separatorItem]];
+ [menu addItemWithTitle: NSLocalizedString(@"Speed Limit", "Dock item") action: @selector(toggleSpeedLimit:) keyEquivalent: @""];
- return fDockMenu;
+ return [menu autorelease];
}
- (NSRect) windowWillUseStandardFrame: (NSWindow *) window defaultFrame: (NSRect) defaultFrame
<nil key="NSUserInterfaceItemIdentifier"/>
<string key="NSWindowContentMinSize">{350, 5}</string>
<object class="NSView" key="NSWindowView" id="303120456">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSButton" id="673219624">
<int key="NSvFlags">292</int>
<string key="NSFrame">{{36, 3}, {36, 18}}</string>
<reference key="NSSuperview" ref="303120456"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="52857407"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="109224088">
<int key="NSvFlags">292</int>
<string key="NSFrame">{{72, 3}, {36, 18}}</string>
<reference key="NSSuperview" ref="303120456"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="403739499"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="617399467">
<int key="NSvFlags">292</int>
<string key="NSFrame">{{0, 3}, {36, 18}}</string>
<reference key="NSSuperview" ref="303120456"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="673219624"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="751933283">
<int key="NSvFlags">258</int>
<string key="NSFrame">{{118, 5}, {279, 14}}</string>
<reference key="NSSuperview" ref="303120456"/>
- <reference key="NSWindow"/>
- <reference key="NSNextKeyView"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="696487414">
<int key="NSCellFlags">67239488</int>
<int key="NSvFlags">256</int>
<string key="NSFrameSize">{515, 224}</string>
<reference key="NSSuperview" ref="306237956"/>
- <reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="1068338331"/>
+ <reference key="NSNextKeyView" ref="365285506"/>
<bool key="NSEnabled">YES</bool>
<object class="_NSCornerView" key="NSCornerView">
<nil key="NSNextResponder"/>
</array>
<string key="NSFrameSize">{515, 224}</string>
<reference key="NSSuperview" ref="87647552"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="675318801"/>
<reference key="NSDocView" ref="675318801"/>
<reference key="NSBGColor" ref="139722115"/>
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{453, 0}, {15, 173}}</string>
<reference key="NSSuperview" ref="87647552"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="306218447"/>
<reference key="NSTarget" ref="87647552"/>
<string key="NSAction">_doScroller:</string>
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{-100, -100}, {451, 15}}</string>
<reference key="NSSuperview" ref="87647552"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="306237956"/>
<int key="NSsFlags">1</int>
<reference key="NSTarget" ref="87647552"/>
</array>
<string key="NSFrame">{{0, 24}, {515, 224}}</string>
<reference key="NSSuperview" ref="303120456"/>
- <reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="365285506"/>
+ <reference key="NSNextKeyView" ref="306237956"/>
<int key="NSsFlags">133648</int>
<reference key="NSVScroller" ref="1068338331"/>
<reference key="NSHScroller" ref="365285506"/>
</object>
</array>
<string key="NSFrameSize">{515, 248}</string>
- <reference key="NSSuperview"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="87647552"/>
</object>
<string key="NSScreenRect">{{0, 0}, {2560, 1440}}</string>
</object>
</array>
</object>
- <object class="NSMenu" id="500860248">
- <string key="NSTitle">Menu</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="546389610">
- <reference key="NSMenu" ref="500860248"/>
- <string key="NSTitle">Pause All</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="246127200"/>
- <reference key="NSMixedImage" ref="330170270"/>
- </object>
- <object class="NSMenuItem" id="441858331">
- <reference key="NSMenu" ref="500860248"/>
- <string key="NSTitle">Resume All</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="246127200"/>
- <reference key="NSMixedImage" ref="330170270"/>
- </object>
- <object class="NSMenuItem" id="250856123">
- <reference key="NSMenu" ref="500860248"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="246127200"/>
- <reference key="NSMixedImage" ref="330170270"/>
- </object>
- <object class="NSMenuItem" id="1036623186">
- <reference key="NSMenu" ref="500860248"/>
- <string key="NSTitle">Speed Limit</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="246127200"/>
- <reference key="NSMixedImage" ref="330170270"/>
- </object>
- </array>
- <string key="NSName"/>
- </object>
<object class="NSCustomObject" id="456998591">
<string key="NSClassName">SUUpdater</string>
</object>
</object>
<int key="connectionID">477</int>
</object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">resumeAllTorrents:</string>
- <reference key="source" ref="30116300"/>
- <reference key="destination" ref="441858331"/>
- </object>
- <int key="connectionID">585</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">stopAllTorrents:</string>
- <reference key="source" ref="30116300"/>
- <reference key="destination" ref="546389610"/>
- </object>
- <int key="connectionID">586</int>
- </object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">showInfo:</string>
</object>
<int key="connectionID">1862</int>
</object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">fDockMenu</string>
- <reference key="source" ref="30116300"/>
- <reference key="destination" ref="500860248"/>
- </object>
- <int key="connectionID">1876</int>
- </object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">setSortReverse:</string>
</object>
<int key="connectionID">2144</int>
</object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">toggleSpeedLimit:</string>
- <reference key="source" ref="30116300"/>
- <reference key="destination" ref="1036623186"/>
- </object>
- <int key="connectionID">2165</int>
- </object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">togglePiecesBar:</string>
<array class="NSMutableArray" key="children"/>
<reference key="parent" ref="612287796"/>
</object>
- <object class="IBObjectRecord">
- <int key="objectID">581</int>
- <reference key="object" ref="500860248"/>
- <array class="NSMutableArray" key="children">
- <reference ref="441858331"/>
- <reference ref="546389610"/>
- <reference ref="1036623186"/>
- <reference ref="250856123"/>
- </array>
- <reference key="parent" ref="0"/>
- <string key="objectName">DockMenu</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">582</int>
- <reference key="object" ref="441858331"/>
- <reference key="parent" ref="500860248"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">583</int>
- <reference key="object" ref="546389610"/>
- <reference key="parent" ref="500860248"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">1574</int>
- <reference key="object" ref="1036623186"/>
- <reference key="parent" ref="500860248"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">1575</int>
- <reference key="object" ref="250856123"/>
- <reference key="parent" ref="500860248"/>
- </object>
<object class="IBObjectRecord">
<int key="objectID">589</int>
<reference key="object" ref="439147874"/>
<string key="1566.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1567.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="157.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="1574.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="1575.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1578.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1591.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="160.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="56.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="57.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="58.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="581.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="582.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="583.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="589.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="598.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="611.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="fActionMenu">NSMenu</string>
<string key="fCheckRatioItem">NSMenuItem</string>
<string key="fClearCompletedButton">NSButton</string>
- <string key="fDockMenu">NSMenu</string>
<string key="fDownloadLimitItem">NSMenuItem</string>
<string key="fDownloadMenu">NSMenu</string>
<string key="fDownloadNoLimitItem">NSMenuItem</string>
<string key="name">fClearCompletedButton</string>
<string key="candidateClassName">NSButton</string>
</object>
- <object class="IBToOneOutletInfo" key="fDockMenu">
- <string key="name">fDockMenu</string>
- <string key="candidateClassName">NSMenu</string>
- </object>
<object class="IBToOneOutletInfo" key="fDownloadLimitItem">
<string key="name">fDownloadLimitItem</string>
<string key="candidateClassName">NSMenuItem</string>