the torrent url sheet will now disable the open button when there is no text; cleanup to the sleep code
This commit is contained in:
parent
35482e453f
commit
0e96185a93
|
@ -99,6 +99,7 @@ typedef enum
|
|||
|
||||
IBOutlet NSWindow * fURLSheetWindow;
|
||||
IBOutlet NSTextField * fURLSheetTextField;
|
||||
IBOutlet NSButton * fURLSheetOpenButton;
|
||||
|
||||
io_connect_t fRootPort;
|
||||
NSTimer * fTimer;
|
||||
|
|
|
@ -337,7 +337,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
//register for sleep notifications
|
||||
IONotificationPortRef notify;
|
||||
io_object_t iterator;
|
||||
if ((fRootPort = IORegisterForSystemPower(self, & notify, sleepCallBack, & iterator)) != 0)
|
||||
if ((fRootPort = IORegisterForSystemPower(self, & notify, sleepCallBack, &iterator)))
|
||||
CFRunLoopAddSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notify), kCFRunLoopCommonModes);
|
||||
else
|
||||
NSLog(@"Could not IORegisterForSystemPower");
|
||||
|
@ -952,13 +952,17 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
[NSApp endSheet: fURLSheetWindow returnCode: 0];
|
||||
}
|
||||
|
||||
- (void) controlTextDidChange: (NSNotification *) notification
|
||||
{
|
||||
[fURLSheetOpenButton setEnabled: ![[fURLSheetTextField stringValue] isEqual: @""]];
|
||||
}
|
||||
|
||||
- (void) urlSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode contextInfo: (void *) contextInfo
|
||||
{
|
||||
[fURLSheetTextField selectText: self];
|
||||
if (returnCode != 1)
|
||||
return;
|
||||
|
||||
#warning disable OK button when blank
|
||||
NSString * urlString = [fURLSheetTextField stringValue];
|
||||
if (![urlString isEqualToString: @""])
|
||||
{
|
||||
|
@ -2380,7 +2384,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
fSoundPlaying = NO;
|
||||
}
|
||||
|
||||
-(void) watcher: (id<UKFileWatcher>) watcher receivedNotification: (NSString *) notification forPath: (NSString *) path
|
||||
- (void) watcher: (id<UKFileWatcher>) watcher receivedNotification: (NSString *) notification forPath: (NSString *) path
|
||||
{
|
||||
if ([notification isEqualToString: UKFileWatcherWriteNotification])
|
||||
{
|
||||
|
@ -3676,31 +3680,25 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
{
|
||||
NSEnumerator * enumerator;
|
||||
Torrent * torrent;
|
||||
BOOL allowSleep;
|
||||
|
||||
switch (messageType)
|
||||
{
|
||||
case kIOMessageSystemWillSleep:
|
||||
//close all connections before going to sleep and remember we should resume when we wake up
|
||||
[fTorrents makeObjectsPerformSelector: @selector(sleep)];
|
||||
|
||||
//wait for running transfers to stop (5 second timeout)
|
||||
NSDate * start = [NSDate date];
|
||||
BOOL timeUp = NO;
|
||||
|
||||
//if there are any running transfers, wait 15 seconds for them to stop
|
||||
enumerator = [fTorrents objectEnumerator];
|
||||
while (!timeUp && (torrent = [enumerator nextObject]))
|
||||
while ([torrent isActive] && !(timeUp = [start timeIntervalSinceNow] < -5.0))
|
||||
while ((torrent = [enumerator nextObject]))
|
||||
if ([torrent isActive])
|
||||
{
|
||||
usleep(100000);
|
||||
[torrent update];
|
||||
//stop all transfers (since some are active) before going to sleep and remember to resume when we wake up
|
||||
[fTorrents makeObjectsPerformSelector: @selector(sleep)];
|
||||
sleep(15);
|
||||
break;
|
||||
}
|
||||
|
||||
IOAllowPowerChange(fRootPort, (long) messageArgument);
|
||||
break;
|
||||
|
||||
case kIOMessageCanSystemSleep:
|
||||
allowSleep = YES;
|
||||
if ([fDefaults boolForKey: @"SleepPrevent"])
|
||||
{
|
||||
//prevent idle sleep unless no torrents are active
|
||||
|
@ -3708,15 +3706,12 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
while ((torrent = [enumerator nextObject]))
|
||||
if ([torrent isActive] && ![torrent isStalled] && ![torrent isError])
|
||||
{
|
||||
allowSleep = NO;
|
||||
break;
|
||||
IOCancelPowerChange(fRootPort, (long) messageArgument);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (allowSleep)
|
||||
IOAllowPowerChange(fRootPort, (long) messageArgument);
|
||||
else
|
||||
IOCancelPowerChange(fRootPort, (long) messageArgument);
|
||||
IOAllowPowerChange(fRootPort, (long) messageArgument);
|
||||
break;
|
||||
|
||||
case kIOMessageSystemHasPoweredOn:
|
||||
|
|
|
@ -3,14 +3,15 @@
|
|||
<data>
|
||||
<int key="IBDocument.SystemTarget">1050</int>
|
||||
<string key="IBDocument.SystemVersion">9C7010</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">648</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">652</string>
|
||||
<string key="IBDocument.AppKitVersion">949.26</string>
|
||||
<string key="IBDocument.HIToolboxVersion">352.00</string>
|
||||
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<integer value="1603"/>
|
||||
<integer value="1480"/>
|
||||
<integer value="2"/>
|
||||
<integer value="21"/>
|
||||
<integer value="1849"/>
|
||||
<integer value="1603"/>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
|
@ -3941,7 +3942,7 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
|
|||
<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
|
||||
<string key="NSWindowContentMinSize">{400, 177}</string>
|
||||
<object class="NSView" key="NSWindowView" id="13427666">
|
||||
<nil key="NSNextResponder"/>
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">256</int>
|
||||
<object class="NSMutableArray" key="NSSubviews">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
|
@ -3974,7 +3975,7 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
|
|||
<reference key="NSSuperview" ref="13427666"/>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSButtonCell" key="NSCell" id="172529900">
|
||||
<int key="NSCellFlags">67239424</int>
|
||||
<int key="NSCellFlags">604110336</int>
|
||||
<int key="NSCellFlags2">134217728</int>
|
||||
<string key="NSContents">Open</string>
|
||||
<reference key="NSSupport" ref="622385820"/>
|
||||
|
@ -4026,7 +4027,8 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
|
|||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrame">{{1, 9}, {400, 177}}</string>
|
||||
<string key="NSFrameSize">{400, 177}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
</object>
|
||||
<string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
|
||||
<string key="NSMinSize">{400, 199}</string>
|
||||
|
@ -6237,6 +6239,22 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
|
|||
</object>
|
||||
<int key="connectionID">3154</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">fURLSheetOpenButton</string>
|
||||
<reference key="source" ref="30116300"/>
|
||||
<reference key="destination" ref="1001733131"/>
|
||||
</object>
|
||||
<int key="connectionID">3156</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">delegate</string>
|
||||
<reference key="source" ref="188853779"/>
|
||||
<reference key="destination" ref="30116300"/>
|
||||
</object>
|
||||
<int key="connectionID">3157</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
|
@ -8525,7 +8543,9 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
|
|||
<string>1815.ImportedFromIB2</string>
|
||||
<string>1846.IBPluginDependency</string>
|
||||
<string>1846.ImportedFromIB2</string>
|
||||
<string>1848.IBEditorWindowLastContentRect</string>
|
||||
<string>1848.IBPluginDependency</string>
|
||||
<string>1848.IBWindowTemplateEditedContentRect</string>
|
||||
<string>1848.ImportedFromIB2</string>
|
||||
<string>1848.windowTemplate.hasMaxSize</string>
|
||||
<string>1848.windowTemplate.hasMinSize</string>
|
||||
|
@ -9092,7 +9112,9 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
|
|||
<reference ref="9"/>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<reference ref="9"/>
|
||||
<string>{{0, 818}, {400, 177}}</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>{{0, 818}, {400, 177}}</string>
|
||||
<reference ref="9"/>
|
||||
<reference ref="9"/>
|
||||
<reference ref="9"/>
|
||||
|
@ -9445,7 +9467,7 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
|
|||
</object>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">3154</int>
|
||||
<int key="maxID">3157</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
|
@ -9624,6 +9646,7 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
|
|||
<string>fTotalDLImageView</string>
|
||||
<string>fTotalTorrentsField</string>
|
||||
<string>fTotalULField</string>
|
||||
<string>fURLSheetOpenButton</string>
|
||||
<string>fURLSheetTextField</string>
|
||||
<string>fURLSheetWindow</string>
|
||||
<string>fUpdater</string>
|
||||
|
@ -9670,6 +9693,7 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
|
|||
<string>NSImageView</string>
|
||||
<string>NSTextField</string>
|
||||
<string>NSTextField</string>
|
||||
<string>NSButton</string>
|
||||
<string>NSTextField</string>
|
||||
<string>NSWindow</string>
|
||||
<string>SUUpdater</string>
|
||||
|
|
|
@ -140,7 +140,7 @@ GroupsWindowController * fGroupsWindowInstance = nil;
|
|||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (BOOL) tableView: (NSTableView *) t acceptDrop: (id <NSDraggingInfo>) info row: (int) newRow
|
||||
- (BOOL) tableView: (NSTableView *) tableView acceptDrop: (id <NSDraggingInfo>) info row: (int) newRow
|
||||
dropOperation: (NSTableViewDropOperation) operation
|
||||
{
|
||||
NSPasteboard * pasteboard = [info draggingPasteboard];
|
||||
|
|
|
@ -1633,6 +1633,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
fFinishedSeeding = NO;
|
||||
|
||||
fWaitToStart = waitToStart && [waitToStart boolValue];
|
||||
fResumeOnWake = NO;
|
||||
|
||||
fOrderValue = orderValue ? [orderValue intValue] : tr_torrentCount(lib) - 1;
|
||||
fGroupValue = groupValue ? [groupValue intValue] : -1;
|
||||
|
|
Loading…
Reference in New Issue