2 #import "GnuViewController.h"
5 @implementation Controller
12 - (void) applicationDidFinishLaunching:(NSNotification *) notification
14 // NSApplication *theApplication = [notification object];
15 NSDictionary *gnutermDefaults;
19 gnutermDefaults = [NSDictionary dictionaryWithObjectsAndKeys: @"400", @"Width", @"300", @"Height", @"Buffered", @"Backing", NULL];
22 activeTerm = keyTerm = [self newGnuTerm:self];
24 myConnection = [NSConnection defaultConnection];
25 [myConnection retain];
26 [myConnection setRootObject:self];
27 if([myConnection registerName:@"gnuplotServer"] == NO) {
28 NSLog(@"Error registering %s\n", "gnuplotServer");
31 #warning PrintingConversion: The current PrintInfo object now depends on context. '[NSPrintInfo sharedPrintInfo]' used to be '[NSApp printInfo]'. This might want to be [[NSPrintOperation currentOperation] printInfo] or possibly [[PageLayout new] printInfo].
32 prInfo = [NSPrintInfo sharedPrintInfo];
33 // prInfo = [[NSPrintOperation currentOperation] printInfo];
34 #warning PrintingConversion: May be able to remove some of the [prInfo setXXXXMargin:] calls
35 [prInfo setLeftMargin:0];
37 [prInfo setRightMargin:0];
39 [prInfo setTopMargin:0];
41 [prInfo setBottomMargin:50];
42 [prInfo setOrientation:NSLandscapeOrientation];
43 [prInfo setHorizontallyCentered:YES];
44 [prInfo setVerticallyCentered:YES];
47 /* Get user Preferences */
48 [[NSUserDefaults standardUserDefaults] registerDefaults: gnutermDefaults]; // TODO this may override existing values
50 [[DefaultSize cellAtIndex:0] setStringValue:[[NSUserDefaults standardUserDefaults] objectForKey:@"Width"]];
51 [[DefaultSize cellAtIndex:1] setStringValue:[[NSUserDefaults standardUserDefaults] objectForKey:@"Height"]];
53 if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"Backing"] isEqualToString:@"Buffered"]) {
54 backing = NSBackingStoreBuffered;
55 [useBufferedSwitch setState:YES];
58 backing = NSBackingStoreRetained;
59 [useBufferedSwitch setState:NO];
62 gvList = [NSMutableArray array];
72 if ([NSBundle loadNibNamed:@"gnuview.nib" owner:self] == NO) {
76 if (win = [activeTerm window]) {
78 (&frame)->origin.x += offset;
79 (&frame)->origin.y -= offset;
80 if ( (offset += 24.0) > 100.0)
83 [win setTitle:[NSString stringWithFormat: @"gnuplot %d", ++gnuviewNum]];
85 [win setFrame:frame display:YES];
86 [win makeKeyAndOrderFront:nil];
94 - (void) setActiveTerm:(id) newTerm
96 if (activeTerm != nil) [activeTerm deactivate:self];
101 - (void) printPScodeInKey:sender
103 [[keyTerm gnuView] print:sender];
106 - (void) setKeyTerm: (id) newTerm
110 [NameField setStringValue:[[keyTerm window] title]];
111 [NameField selectText:self];
114 - (void) setKeyTitle:sender
116 [[keyTerm window] setTitle:[NameField stringValue]];
117 [[NameField window] performClose:self];
120 - (void) executePScode:(NSString *) PSstring termTitle:(NSString *) title;
122 NSLog(@"Request for window: %@\n", title);
124 if (activeTerm == nil) [self newGnuTerm:self];
126 [[activeTerm gnuView] executePS:PSstring];