Skip to content

Commit

Permalink
Console window is now available as a client (pseudo-)plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
cstawarz committed Jun 7, 2016
1 parent e902384 commit 2fa427e
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions apps/client/MWClientInstance.m
Expand Up @@ -12,6 +12,7 @@
#import <MWorksCore/Client.h>
#import <MWorksCocoa/MWCocoaEvent.h>
#import <MWorksCocoa/MWCocoaEventFunctor.h>
#import <MWorksCocoa/MWConsoleController.h>
#import <MWorksCocoa/MWWindowController.h>
#import <MWorksCocoa/MWNotebook.h>
#import <MWorksCocoa/NSString+MWorksCocoaAdditions.h>
Expand Down Expand Up @@ -843,7 +844,15 @@ - (void) loadPlugins {
[[grouped_plugin_controller window] orderOut:self];
[grouped_plugin_controller setCustomColor:self.headerColor];
[grouped_plugin_controller setWindowFrameAutosaveName:self.serverURL];


// Add console, which is always available
MWConsoleController *console = [[MWConsoleController alloc] init];
[console setDelegate:self];
[console.window bind:@"displayPatternTitle1"
toObject:self
withKeyPath:@"serverURL"
options:@{NSDisplayPatternBindingOption: @"Console (%{title1}@)"}];
[self addPlugin:console withName:@"Console"];

NSFileManager *fm = [NSFileManager defaultManager];

Expand Down Expand Up @@ -890,21 +899,11 @@ - (void) loadPlugins {
continue;
}

NSWindowController *controller = Nil;

for(int j=0; j < [toplevel count]; j++){
NSObject *obj = [toplevel objectAtIndex:j];
//NSLog(@"object = %d", obj);
if([obj isKindOfClass:[NSWindowController class]]){
controller = (NSWindowController *)obj;
[controller loadWindow];
[controller setWindowFrameAutosaveName:[plugin_file stringByDeletingPathExtension]];
[pluginWindows addObject:controller];

// also, add the window to the grouped_plugin_controller
[grouped_plugin_controller addPluginWindow:[controller window] withName:[[controller window] title]];
[grouped_plugin_controller setCurrentPluginIndex:0];

[self addPlugin:(NSWindowController *)obj withName:[plugin_file stringByDeletingPathExtension]];
//NSLog(@"object is a controller (%d)", [pluginWindows count]);
break;
}
Expand All @@ -928,6 +927,17 @@ - (void) loadPlugins {
}


- (void)addPlugin:(NSWindowController *)controller withName:(NSString *)name {
[controller loadWindow];
[controller setWindowFrameAutosaveName:name];
[pluginWindows addObject:controller];

// also, add the window to the grouped_plugin_controller
[grouped_plugin_controller addPluginWindow:[controller window] withName:[[controller window] title]];
[grouped_plugin_controller setCurrentPluginIndex:0];
}


- (NSArray *)pluginWindows {
return pluginWindows;
}
Expand Down

0 comments on commit 2fa427e

Please sign in to comment.