#4920 On Lion, use window restoration on the message log and stats window

This commit is contained in:
Mitchell Livingston
2012-05-27 22:31:58 +00:00
parent ca7654d8cd
commit bcde8ebef6
9 changed files with 211 additions and 126 deletions

View File

@@ -23,6 +23,7 @@
*****************************************************************************/
#import "MessageWindowController.h"
#import "Controller.h"
#import "NSApplicationAdditions.h"
#import "NSMutableArrayAdditions.h"
#import "NSStringAdditions.h"
@@ -57,6 +58,8 @@
[window setFrameAutosaveName: @"MessageWindowFrame"];
[window setFrameUsingName: @"MessageWindowFrame"];
[window setRestorationClass: [self class]];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(resizeColumn)
name: @"NSTableViewColumnDidResizeNotification" object: fMessageTable];
@@ -149,8 +152,7 @@
{
if (!fTimer)
{
fTimer = [NSTimer scheduledTimerWithTimeInterval: UPDATE_SECONDS target: self
selector: @selector(updateLog:) userInfo: nil repeats: YES];
fTimer = [NSTimer scheduledTimerWithTimeInterval: UPDATE_SECONDS target: self selector: @selector(updateLog:) userInfo: nil repeats: YES];
[self updateLog: nil];
}
}
@@ -161,6 +163,21 @@
fTimer = nil;
}
+ (void) restoreWindowWithIdentifier: (NSString *) identifier state: (NSCoder *) state completionHandler: (void (^)(NSWindow *, NSError *)) completionHandler
{
NSAssert1([identifier isEqualToString: @"MessageWindow"], @"Trying to restore unexpected identifier %@", identifier);
NSWindow * window = [[(Controller *)[NSApp delegate] messageWindowController] window];
completionHandler(window, nil);
}
- (void) window: (NSWindow *) window didDecodeRestorableState: (NSCoder *) coder
{
[fTimer invalidate];
fTimer = [NSTimer scheduledTimerWithTimeInterval: UPDATE_SECONDS target: self selector: @selector(updateLog:) userInfo: nil repeats: YES];
[self updateLog: nil];
}
- (void) updateLog: (NSTimer *) timer
{
tr_msg_list * messages;