Display a warning when in debug mode.

This commit is contained in:
Mitchell Livingston 2006-09-03 17:06:43 +00:00
parent 4c100c1bf9
commit 7297f8232c
7 changed files with 34 additions and 10 deletions

View File

@ -6,6 +6,8 @@
CLASS = MessageWindowController;
LANGUAGE = ObjC;
OUTLETS = {
fDebugWarningField = NSTextField;
fDebugWarningIcon = NSImageView;
fLevelButton = NSPopUpButton;
fScrollView = NSScrollView;
fTextView = NSTextView;

View File

@ -63,7 +63,7 @@
fCheckImage = [NSImage imageNamed: @"NSMenuCheckmark"];
fTorrents = [[NSArray alloc] init];
fPeers = [[NSMutableArray alloc] initWithCapacity: 6];
fPeers = [[NSMutableArray alloc] initWithCapacity: 30];
fFiles = [[NSMutableArray alloc] initWithCapacity: 6];
[fFileTable setDoubleAction: @selector(revealFile:)];

View File

@ -35,6 +35,9 @@
NSDictionary * fAttributes;
int fLines;
IBOutlet NSTextField * fDebugWarningField;
IBOutlet NSImageView * fDebugWarningIcon;
}
- (void) updateLog: (NSTimer *) timer;

View File

@ -29,9 +29,15 @@
#define LEVEL_INFO 1
#define LEVEL_DEBUG 2
#define UPDATE_SECONDS 0.35
#define UPDATE_SECONDS 0.4
#define MAX_LINES 1000
@interface MessageWindowController (Private)
- (void) setDebugWarningHidden: (BOOL) hide;
@end
@implementation MessageWindowController
- (id) initWithWindowNibName: (NSString *) name
@ -80,6 +86,8 @@
[[NSUserDefaults standardUserDefaults] setInteger: level forKey: @"MessageLevel"];
}
[self setDebugWarningHidden: level != TR_MSG_DBG];
tr_setMessageLevel(level);
tr_setMessageQueuing(1);
}
@ -115,8 +123,7 @@
//remove the first line if at max number of lines
if (fLines == MAX_LINES)
{
NSString * text = [fTextView string];
unsigned int loc = [text rangeOfString: @"\n"].location;
unsigned int loc = [[fTextView string] rangeOfString: @"\n"].location;
if (loc != NSNotFound)
[[fTextView textStorage] deleteCharactersInRange: NSMakeRange(0, loc + 1)];
}
@ -145,6 +152,8 @@
else
level = TR_MSG_ERR;
[self setDebugWarningHidden: level != TR_MSG_DBG];
tr_setMessageLevel(level);
[[NSUserDefaults standardUserDefaults] setInteger: level forKey: @"MessageLevel"];
}
@ -187,4 +196,10 @@
[string release];
}
- (void) setDebugWarningHidden: (BOOL) hide
{
[fDebugWarningField setHidden: hide];
[fDebugWarningIcon setHidden: hide];
}
@end

View File

@ -436,8 +436,7 @@
- (NSString *) torrentLocationString
{
return fPrivateTorrent ? @"Transmission Support Folder"
: [fPublicTorrentLocation stringByAbbreviatingWithTildeInPath];
return fPrivateTorrent ? @"Transmission Support Folder" : [fPublicTorrentLocation stringByAbbreviatingWithTildeInPath];
}
- (NSString *) dataLocation
@ -530,7 +529,6 @@
for (i = 0; i < totalPeers; i++)
{
peer = peers[i];
[peerDics addObject: [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool: peer.isConnected], @"Connected",
[NSString stringWithCString: (char *) peer.addr encoding: NSUTF8StringEncoding], @"IP",
@ -640,8 +638,8 @@
for (i = 0; i < count; i++)
{
file = fInfo->files[i];
[files addObject: [NSDictionary dictionaryWithObjectsAndKeys: [[self downloadFolder]
stringByAppendingPathComponent: [NSString stringWithUTF8String: file.name]], @"Name",
[files addObject: [NSDictionary dictionaryWithObjectsAndKeys:
[[self downloadFolder] stringByAppendingPathComponent: [NSString stringWithUTF8String: file.name]], @"Name",
[NSNumber numberWithUnsignedLongLong: file.length], @"Size", nil]];
}

View File

@ -90,12 +90,18 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
fProgressEndGreen = [NSImage imageNamed: @"ProgressBarEndGreen.png"];
fProgressEndAdvanced = [NSImage imageNamed: @"ProgressBarEndAdvanced.png"];
fErrorImage = [NSImage imageNamed: @"Error.tiff"];
fErrorImage = [[NSImage imageNamed: @"Error.tiff"] copy];
[fErrorImage setFlipped: YES];
}
return self;
}
- (void) dealloc
{
[fErrorImage release];
[super dealloc];
}
- (void) setTorrent: (Torrent *) torrent
{
fTorrent = torrent;