mirror of
https://github.com/transmission/transmission
synced 2025-03-03 02:05:19 +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:
parent
d91cd60504
commit
6d15738403
4 changed files with 19 additions and 3 deletions
|
@ -5,7 +5,11 @@
|
||||||
ACTIONS = {changeLevel = id; clearLog = id; };
|
ACTIONS = {changeLevel = id; clearLog = id; };
|
||||||
CLASS = MessageWindowController;
|
CLASS = MessageWindowController;
|
||||||
LANGUAGE = ObjC;
|
LANGUAGE = ObjC;
|
||||||
OUTLETS = {fLevelButton = NSPopUpButton; fTextView = NSTextView; };
|
OUTLETS = {
|
||||||
|
fLevelButton = NSPopUpButton;
|
||||||
|
fScrollView = NSScrollView;
|
||||||
|
fTextView = NSTextView;
|
||||||
|
};
|
||||||
SUPERCLASS = NSWindowController;
|
SUPERCLASS = NSWindowController;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
BIN
macosx/English.lproj/MessageWindow.nib/keyedobjects.nib
generated
BIN
macosx/English.lproj/MessageWindow.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -27,6 +27,8 @@
|
||||||
@interface MessageWindowController : NSWindowController
|
@interface MessageWindowController : NSWindowController
|
||||||
{
|
{
|
||||||
IBOutlet NSTextView * fTextView;
|
IBOutlet NSTextView * fTextView;
|
||||||
|
IBOutlet NSScrollView * fScrollView;
|
||||||
|
|
||||||
IBOutlet NSPopUpButton * fLevelButton;
|
IBOutlet NSPopUpButton * fLevelButton;
|
||||||
|
|
||||||
NSLock * fLock;
|
NSLock * fLock;
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#define LEVEL_INFO 1
|
#define LEVEL_INFO 1
|
||||||
#define LEVEL_DEBUG 2
|
#define LEVEL_DEBUG 2
|
||||||
|
|
||||||
#define UPDATE_SECONDS 0.5
|
#define UPDATE_SECONDS 0.35
|
||||||
|
|
||||||
@interface MessageWindowController (Private)
|
@interface MessageWindowController (Private)
|
||||||
|
|
||||||
|
@ -123,16 +123,24 @@ void addMessage(int level, const char * message)
|
||||||
if ([fBufferArray count] == 0)
|
if ([fBufferArray count] == 0)
|
||||||
return;
|
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];
|
[fLock lock];
|
||||||
|
|
||||||
NSEnumerator * enumerator = [fBufferArray objectEnumerator];
|
NSEnumerator * enumerator = [fBufferArray objectEnumerator];
|
||||||
NSAttributedString * messageString;
|
NSAttributedString * messageString;
|
||||||
while ((messageString = [enumerator nextObject]))
|
while ((messageString = [enumerator nextObject]))
|
||||||
[[fTextView textStorage] appendAttributedString: messageString];
|
[[fTextView textStorage] appendAttributedString: messageString];
|
||||||
|
|
||||||
[fBufferArray removeAllObjects];
|
[fBufferArray removeAllObjects];
|
||||||
|
|
||||||
[fLock unlock];
|
[fLock unlock];
|
||||||
|
|
||||||
|
if (shouldScroll)
|
||||||
|
[fTextView scrollRangeToVisible: NSMakeRange([[fTextView string] length], 0)];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) changeLevel: (id) sender
|
- (void) changeLevel: (id) sender
|
||||||
|
@ -145,6 +153,8 @@ void addMessage(int level, const char * message)
|
||||||
else
|
else
|
||||||
level = TR_MSG_ERR;
|
level = TR_MSG_ERR;
|
||||||
|
|
||||||
|
[self updateLog: nil];
|
||||||
|
|
||||||
tr_setMessageLevel(level);
|
tr_setMessageLevel(level);
|
||||||
[[NSUserDefaults standardUserDefaults] setInteger: level forKey: @"MessageLevel"];
|
[[NSUserDefaults standardUserDefaults] setInteger: level forKey: @"MessageLevel"];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue