|
8 | 8 | #import "PlainTextDocument.h" |
9 | 9 | #import "DocumentMode.h" |
10 | 10 | #import "BorderedTextField.h" |
| 11 | +#import "SEEWorkspaceDocument.h" |
11 | 12 |
|
12 | 13 | @interface SEEPlainTextEditorTopBarViewController () <PopUpButtonDelegate> |
13 | 14 | @property (nonatomic, strong) IBOutlet BorderedTextField *writtenByTextField; |
14 | 15 | @property (nonatomic, strong) IBOutlet BorderedTextField *positionTextField; |
15 | 16 | @property (nonatomic, strong) IBOutlet BorderedTextField *docinfoTextField; |
16 | 17 | @property (nonatomic, strong) IBOutlet NSButton *splitButton; |
17 | 18 | @property (nonatomic, strong) IBOutlet NSImageView *waitPipeIconImageView; |
| 19 | +@property (nonatomic, strong) IBOutlet NSButton *workspaceButton; |
18 | 20 | @property (nonatomic, strong) IBOutlet NSView *bottomBarLayerBackedView; |
19 | 21 | @property (nonatomic, strong) NSMutableSet *registeredNotifications; |
20 | 22 |
|
@@ -55,10 +57,15 @@ - (instancetype)initWithPlainTextEditor:(PlainTextEditor *)anEditor { |
55 | 57 | [weakSelf updateSymbolPopUpContent]; |
56 | 58 | [weakSelf adjustLayout]; |
57 | 59 | }]]; |
| 60 | + [set addObject:[center addObserverForName:PlainTextDocumentWorkspaceDidChangeNotification |
| 61 | + object:document queue:mainQueue |
| 62 | + usingBlock:^(NSNotification *aNotification) { |
| 63 | + [weakSelf updateSymbolPopUpContent]; |
| 64 | + [weakSelf adjustLayout]; |
| 65 | + }]]; |
58 | 66 |
|
59 | 67 | set; |
60 | 68 | }); |
61 | | - |
62 | 69 | } |
63 | 70 | return self; |
64 | 71 | } |
@@ -156,16 +163,22 @@ - (void)adjustLayout { |
156 | 163 | NSRect bounds = self.view.bounds; |
157 | 164 | CGFloat xPosition = NSMinX(bounds); |
158 | 165 | BOOL isWaiting = [document isWaiting]; |
| 166 | + BOOL hasWorkspace = (document.workspace != nil); |
159 | 167 | BOOL hasSymbols = [[document documentMode] hasSymbols]; |
160 | 168 |
|
161 | 169 | BorderedTextField *positionTextField = self.positionTextField; |
162 | 170 | PopUpButton *symbolPopUpButton = self.symbolPopUpButton; |
163 | 171 | // document is waiting for some input from a pipe so show an indicator for that |
164 | 172 | self.waitPipeIconImageView.hidden = !isWaiting; |
165 | | - [positionTextField setHasLeftBorder:isWaiting]; |
| 173 | + [positionTextField setHasLeftBorder:isWaiting || hasWorkspace]; |
166 | 174 | if (isWaiting) { |
167 | 175 | xPosition += 19.; |
168 | 176 | } |
| 177 | + |
| 178 | + self.workspaceButton.hidden = !hasWorkspace; |
| 179 | + if (hasWorkspace) { |
| 180 | + xPosition += 19.; |
| 181 | + } |
169 | 182 |
|
170 | 183 | // if there are no symbols hide the symbols popup |
171 | 184 | [symbolPopUpButton setHidden:!hasSymbols]; |
@@ -234,6 +247,18 @@ - (IBAction)splitToggleButtonAction:(id)sender { |
234 | 247 | [self.editor.windowControllerTabContext toggleEditorSplit]; |
235 | 248 | } |
236 | 249 |
|
| 250 | +- (IBAction)workspaceButtonAction:(id)sender { |
| 251 | + SEEDocumentController * documentController = (SEEDocumentController *)[NSDocumentController sharedDocumentController]; |
| 252 | + |
| 253 | + [documentController openWorkspace:self.editor.document.workspace |
| 254 | + display:YES |
| 255 | + withCompletionHandler:^(NSDocument *document, BOOL documentWasAlreadyOpen, NSError *error) { |
| 256 | + if ([document isKindOfClass:[SEEWorkspaceDocument class]]) { |
| 257 | + [(SEEWorkspaceDocument *)document selectFileWithURL:self.editor.document.fileURL]; |
| 258 | + } |
| 259 | + }]; |
| 260 | +} |
| 261 | + |
237 | 262 | - (IBAction)keyboardActivateSymbolPopUp { |
238 | 263 | [self.symbolPopUpButton performClick:self.editor]; |
239 | 264 | } |
|
0 commit comments