1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-02 17:55:22 +00:00

Empty (and display) buffer right away when changing message level, and update the log a little more often.

This commit is contained in:
Mitchell Livingston 2006-08-22 01:08:44 +00:00
parent d91cd60504
commit 6d15738403
4 changed files with 19 additions and 3 deletions

View file

@ -5,7 +5,11 @@
ACTIONS = {changeLevel = id; clearLog = id; };
CLASS = MessageWindowController;
LANGUAGE = ObjC;
OUTLETS = {fLevelButton = NSPopUpButton; fTextView = NSTextView; };
OUTLETS = {
fLevelButton = NSPopUpButton;
fScrollView = NSScrollView;
fTextView = NSTextView;
};
SUPERCLASS = NSWindowController;
}
);

View file

@ -27,6 +27,8 @@
@interface MessageWindowController : NSWindowController
{
IBOutlet NSTextView * fTextView;
IBOutlet NSScrollView * fScrollView;
IBOutlet NSPopUpButton * fLevelButton;
NSLock * fLock;

View file

@ -29,7 +29,7 @@
#define LEVEL_INFO 1
#define LEVEL_DEBUG 2
#define UPDATE_SECONDS 0.5
#define UPDATE_SECONDS 0.35
@interface MessageWindowController (Private)
@ -123,16 +123,24 @@ void addMessage(int level, const char * message)
if ([fBufferArray count] == 0)
return;
//keep scrolled to bottom if already at bottom or there is no scroll bar yet
BOOL shouldScroll = NO;
NSScroller * scroller = [fScrollView verticalScroller];
if ([scroller floatValue] == 1.0 || [scroller isHidden] || [scroller knobProportion] == 1.0)
shouldScroll = YES;
[fLock lock];
NSEnumerator * enumerator = [fBufferArray objectEnumerator];
NSAttributedString * messageString;
while ((messageString = [enumerator nextObject]))
[[fTextView textStorage] appendAttributedString: messageString];
[fBufferArray removeAllObjects];
[fLock unlock];
if (shouldScroll)
[fTextView scrollRangeToVisible: NSMakeRange([[fTextView string] length], 0)];
}
- (void) changeLevel: (id) sender
@ -145,6 +153,8 @@ void addMessage(int level, const char * message)
else
level = TR_MSG_ERR;
[self updateLog: nil];
tr_setMessageLevel(level);
[[NSUserDefaults standardUserDefaults] setInteger: level forKey: @"MessageLevel"];
}