From 894b33d0bfae6e235d47d8edaae98e4bf8d8b28e Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Thu, 25 Aug 2016 14:08:03 +0200 Subject: [PATCH] Set frame autosave name of HTML output windows during creation --- Frameworks/DocumentWindow/src/DocumentController.mm | 2 +- Frameworks/HTMLOutputWindow/src/HTMLOutputWindow.h | 3 ++- Frameworks/HTMLOutputWindow/src/HTMLOutputWindow.mm | 13 ++++++++++--- Frameworks/HTMLOutputWindow/target | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Frameworks/DocumentWindow/src/DocumentController.mm b/Frameworks/DocumentWindow/src/DocumentController.mm index 9525c333..fbe6876c 100644 --- a/Frameworks/DocumentWindow/src/DocumentController.mm +++ b/Frameworks/DocumentWindow/src/DocumentController.mm @@ -2087,7 +2087,7 @@ namespace } if(!target) - target = [HTMLOutputWindowController new]; + target = [[HTMLOutputWindowController alloc] initWithIdentifier:[[NSUUID alloc] initWithUUIDString:to_ns(aRunner->uuid())]]; target.commandRunner = _runner; self.htmlOutputWindowController = target; diff --git a/Frameworks/HTMLOutputWindow/src/HTMLOutputWindow.h b/Frameworks/HTMLOutputWindow/src/HTMLOutputWindow.h index 88b4282c..bcdd7112 100644 --- a/Frameworks/HTMLOutputWindow/src/HTMLOutputWindow.h +++ b/Frameworks/HTMLOutputWindow/src/HTMLOutputWindow.h @@ -7,8 +7,9 @@ PUBLIC @interface HTMLOutputWindowController : NSObject @property (nonatomic) command::runner_ptr commandRunner; @property (nonatomic, readonly) BOOL running; @property (nonatomic, readonly) BOOL needsNewWebView; -+ (HTMLOutputWindowController*)HTMLOutputWindowWithRunner:(command::runner_ptr const&)aRunner; ++ (instancetype)HTMLOutputWindowWithRunner:(command::runner_ptr const&)aRunner; +- (instancetype)initWithIdentifier:(NSUUID*)anIdentifier; - (void)showWindow:(id)sender; - (void)close; @end diff --git a/Frameworks/HTMLOutputWindow/src/HTMLOutputWindow.mm b/Frameworks/HTMLOutputWindow/src/HTMLOutputWindow.mm index cc50e8d2..e30b5957 100644 --- a/Frameworks/HTMLOutputWindow/src/HTMLOutputWindow.mm +++ b/Frameworks/HTMLOutputWindow/src/HTMLOutputWindow.mm @@ -2,6 +2,7 @@ #import #import #import +#import #import OAK_DEBUG_VAR(HTMLOutputWindow); @@ -14,7 +15,7 @@ OAK_DEBUG_VAR(HTMLOutputWindow); @end @implementation HTMLOutputWindowController -- (id)init +- (instancetype)init { if(self = [super init]) { @@ -40,6 +41,13 @@ OAK_DEBUG_VAR(HTMLOutputWindow); return self; } +- (instancetype)initWithIdentifier:(NSUUID*)anIdentifier +{ + if(self = [self init]) + self.window.frameAutosaveName = [NSString stringWithFormat:@"HTML output for %@", anIdentifier.UUIDString]; + return self; +} + - (void)applicationDidActivate:(NSNotification*)notification { // Starting with 10.11 behavior must be changed after current event loop cycle @@ -59,7 +67,7 @@ OAK_DEBUG_VAR(HTMLOutputWindow); + (HTMLOutputWindowController*)HTMLOutputWindowWithRunner:(command::runner_ptr const&)aRunner { D(DBF_HTMLOutputWindow, bug("%s\n", to_s(aRunner->uuid()).c_str());); - HTMLOutputWindowController* res = [[self alloc] init]; + HTMLOutputWindowController* res = [[self alloc] initWithIdentifier:[[NSUUID alloc] initWithUUIDString:to_ns(aRunner->uuid())]]; [res setCommandRunner:aRunner]; return res; } @@ -79,7 +87,6 @@ OAK_DEBUG_VAR(HTMLOutputWindow); { _commandRunner = aRunner; - self.window.frameAutosaveName = [NSString stringWithFormat:@"HTML output for %@", [NSString stringWithCxxString:_commandRunner->uuid()]]; [self.htmlOutputView loadRequest:URLRequestForCommandRunner(_commandRunner) environment:_commandRunner->environment() autoScrolls:_commandRunner->auto_scroll_output()]; [self showWindow:self]; } diff --git a/Frameworks/HTMLOutputWindow/target b/Frameworks/HTMLOutputWindow/target index f2465ac3..32951ce3 100644 --- a/Frameworks/HTMLOutputWindow/target +++ b/Frameworks/HTMLOutputWindow/target @@ -1,4 +1,4 @@ SOURCES = src/*.mm EXPORT = src/HTMLOutputWindow.h -LINK += HTMLOutput OakAppKit OakFoundation command +LINK += HTMLOutput OakAppKit OakFoundation command ns FRAMEWORKS = Cocoa