Changeset 394 for trunk/macosx/Controller.m
- Timestamp:
- Jun 19, 2006, 11:07:28 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Controller.m
r393 r394 65 65 fInfoController = [[InfoWindowController alloc] initWithWindowNibName: @"InfoWindow"]; 66 66 fPrefsController = [[PrefsController alloc] initWithWindowNibName: @"PrefsWindow"]; 67 fBadger = [[Badger alloc] init]; 68 69 //check and register Growl if it is installed for this user or all users 70 NSFileManager * manager = [NSFileManager defaultManager]; 71 fHasGrowl = [manager fileExistsAtPath: GROWL_PATH] 72 || [manager fileExistsAtPath: [NSHomeDirectory() stringByAppendingPathComponent: GROWL_PATH]]; 73 [self growlRegister]; 67 74 } 68 75 return self; … … 140 147 } 141 148 else 142 NSLog( @"Could not IORegisterForSystemPower");149 NSLog(@"Could not IORegisterForSystemPower"); 143 150 144 151 //load torrents from history … … 168 175 currentSortItem = fDateSortItem; 169 176 [currentSortItem setState: NSOnState]; 170 171 //check and register Growl if it is installed for this user or all users172 NSFileManager * manager = [NSFileManager defaultManager];173 fHasGrowl = [manager fileExistsAtPath: GROWL_PATH]174 || [manager fileExistsAtPath: [[NSString stringWithFormat: @"~%@",175 GROWL_PATH] stringByExpandingTildeInPath]];176 [self growlRegister: self];177 178 //initialize badging179 fBadger = [[Badger alloc] init];180 177 181 178 //set upload limit action button … … 234 231 [fWindow makeKeyAndOrderFront: nil]; 235 232 236 [fInfoController updateInfoForTorrents: [self torrentsAtIndexes: 237 [fTableView selectedRowIndexes]]]; 233 [fInfoController updateInfoForTorrents: [self torrentsAtIndexes: [fTableView selectedRowIndexes]]]; 238 234 if ([fDefaults boolForKey: @"InfoVisible"]) 239 235 [self showInfo: nil]; … … 279 275 280 276 - (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode 281 277 contextInfo: (void *) contextInfo 282 278 { 283 279 [NSApp stopModal]; … … 416 412 int count = [fTorrents count]; 417 413 [fTotalTorrentsField setStringValue: [NSString stringWithFormat: 418 414 @"%d Transfer%s", count, count == 1 ? "" : "s"]]; 419 415 } 420 416 … … 667 663 NSSavePanel * panel = [NSSavePanel savePanel]; 668 664 [panel setRequiredFileType: @"torrent"]; 665 [panel setCanSelectHiddenExtension: NO]; 669 666 [panel setExtensionHidden: NO]; 670 [panel setCanSelectHiddenExtension: NO];671 667 672 668 [panel beginSheetForDirectory: nil file: [torrent name] … … 872 868 { 873 869 [fPrefsController setLimitEnabled: (sender == fUploadLimitItem || sender == fDownloadLimitItem) 874 type: (sender == fUploadLimitItem || sender == fUploadNoLimitItem) 875 ? @"Upload" : @"Download"]; 870 type: (sender == fUploadLimitItem || sender == fUploadNoLimitItem) ? @"Upload" : @"Download"]; 876 871 } 877 872 … … 971 966 if (![[pasteboard types] containsObject: NSFilenamesPboardType] 972 967 || [[[pasteboard propertyListForType: NSFilenamesPboardType] 973 pathsMatchingExtensions: [NSArray arrayWithObject: @"torrent"]] 974 count] == 0) 968 pathsMatchingExtensions: [NSArray arrayWithObject: @"torrent"]] count] == 0) 975 969 return NSDragOperationNone; 976 970 … … 1346 1340 } 1347 1341 1348 - (void) sleepCallBack: (natural_t) messageType argument: 1349 (void *) messageArgument 1342 - (void) sleepCallBack: (natural_t) messageType argument: (void *) messageArgument 1350 1343 { 1351 1344 NSEnumerator * enumerator; … … 1400 1393 } 1401 1394 1402 - (NSRect) windowWillUseStandardFrame: (NSWindow *) w 1403 defaultFrame: (NSRect) defaultFrame 1395 - (NSRect) windowWillUseStandardFrame: (NSWindow *) w defaultFrame: (NSRect) defaultFrame 1404 1396 { 1405 1397 NSRect windowRect = [fWindow frame]; … … 1439 1431 - (void) notifyGrowl: (NSString * ) file 1440 1432 { 1441 NSString * growlScript; 1442 NSAppleScript * appleScript; 1443 NSDictionary * error; 1444 1445 if( !fHasGrowl ) 1433 if (!fHasGrowl) 1446 1434 return; 1447 1435 1448 growlScript = [NSString stringWithFormat:1436 NSString * growlScript = [NSString stringWithFormat: 1449 1437 @"tell application \"System Events\"\n" 1450 1438 " if exists application process \"GrowlHelperApp\" then\n" … … 1457 1445 " end if\n" 1458 1446 "end tell", file]; 1459 appleScript = [[NSAppleScript alloc] initWithSource: growlScript];1460 if( ![appleScript executeAndReturnError: &error] )1461 {1462 NSLog( @"Growl notify failed" );1463 }1447 1448 NSAppleScript * appleScript = [[NSAppleScript alloc] initWithSource: growlScript]; 1449 NSDictionary * error; 1450 if (![appleScript executeAndReturnError: &error]) 1451 NSLog(@"Growl notify failed"); 1464 1452 [appleScript release]; 1465 1453 } 1466 1454 1467 - (void) growlRegister: (id) sender 1468 { 1469 NSString * growlScript; 1470 NSAppleScript * appleScript; 1471 NSDictionary * error; 1472 1473 if( !fHasGrowl ) 1455 - (void) growlRegister 1456 { 1457 if (!fHasGrowl) 1474 1458 return; 1475 1459 1476 growlScript = [NSString stringWithFormat:1460 NSString * growlScript = [NSString stringWithFormat: 1477 1461 @"tell application \"System Events\"\n" 1478 1462 " if exists application process \"GrowlHelperApp\" then\n" … … 1486 1470 "end tell"]; 1487 1471 1488 appleScript = [[NSAppleScript alloc] initWithSource: growlScript]; 1489 if( ![appleScript executeAndReturnError: &error] ) 1490 { 1491 NSLog( @"Growl registration failed" ); 1492 } 1472 NSAppleScript * appleScript = [[NSAppleScript alloc] initWithSource: growlScript]; 1473 NSDictionary * error; 1474 if (![appleScript executeAndReturnError: &error]) 1475 NSLog(@"Growl registration failed"); 1493 1476 [appleScript release]; 1494 1477 }
Note: See TracChangeset
for help on using the changeset viewer.