From 2ecc0bb27275481f7093fd869eda6b3fc11971f0 Mon Sep 17 00:00:00 2001 From: Johan Paulsson Date: Wed, 27 Feb 2013 11:44:58 +0000 Subject: osx gui moved latex settings to preferences --- tikzit/English.lproj/UserDefaults.plist | 6 +- tikzit/src/osx/AppDelegate.m | 20 --- tikzit/src/osx/PreferenceController.h | 16 +++ tikzit/src/osx/PreferenceController.m | 19 ++- tikzit/src/osx/Preferences.xib | 233 +++++++++++++++++++++++--------- tikzit/src/osx/PreviewController.m | 27 ++-- 6 files changed, 227 insertions(+), 94 deletions(-) diff --git a/tikzit/English.lproj/UserDefaults.plist b/tikzit/English.lproj/UserDefaults.plist index 374f6ef..cdd5c8f 100644 --- a/tikzit/English.lproj/UserDefaults.plist +++ b/tikzit/English.lproj/UserDefaults.plist @@ -2,7 +2,9 @@ - testDefaultsHandler - foo + net.sourceforge.tikzit.pdflatexpath + /usr/texbin/pdflatex + net.sourceforge.tikzit.previewfocus + diff --git a/tikzit/src/osx/AppDelegate.m b/tikzit/src/osx/AppDelegate.m index ad1d407..87d3ae0 100644 --- a/tikzit/src/osx/AppDelegate.m +++ b/tikzit/src/osx/AppDelegate.m @@ -77,34 +77,14 @@ } + (void)setDefaults{ - NSLog(@"Setting defaults..."); - NSString *userDefaultsValuesPath; NSDictionary *userDefaultsValuesDict; - NSDictionary *initialValuesDict; - NSArray *resettableUserDefaultsKeys; - // load the default values for the user defaults userDefaultsValuesPath=[[NSBundle mainBundle] pathForResource:@"UserDefaults" ofType:@"plist"]; userDefaultsValuesDict=[NSDictionary dictionaryWithContentsOfFile:userDefaultsValuesPath]; - NSLog(@"Defaults dict: %@",userDefaultsValuesDict); - - // set them in the standard user defaults [[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsValuesDict]; - - // if your application supports resetting a subset of the defaults to - // factory values, you should set those values - // in the shared user defaults controller - //resettableUserDefaultsKeys=[NSArray arrayWithObjects:@"Value1",@"Value2",@"Value3",nil]; - //initialValuesDict=[userDefaultsValuesDict dictionaryWithValuesForKeys:resettableUserDefaultsKeys]; - - // Set the initial values in the shared user defaults controller - //[[NSUserDefaultsController sharedUserDefaultsController] setInitialValues:initialValuesDict]; - - - NSLog(@"Done with defaults..."); } - (void)applicationWillTerminate:(NSNotification *)notification { diff --git a/tikzit/src/osx/PreferenceController.h b/tikzit/src/osx/PreferenceController.h index 9143851..bc6ed67 100644 --- a/tikzit/src/osx/PreferenceController.h +++ b/tikzit/src/osx/PreferenceController.h @@ -5,6 +5,22 @@ // Created by Karl Johan Paulsson on 26/02/2013. // Copyright (c) 2013 Aleks Kissinger. All rights reserved. // +// +// This file is part of TikZiT. +// +// TikZiT is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// TikZiT is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with TikZiT. If not, see . +// #import diff --git a/tikzit/src/osx/PreferenceController.m b/tikzit/src/osx/PreferenceController.m index e2c9984..75d7ef7 100644 --- a/tikzit/src/osx/PreferenceController.m +++ b/tikzit/src/osx/PreferenceController.m @@ -5,6 +5,22 @@ // Created by Karl Johan Paulsson on 26/02/2013. // Copyright (c) 2013 Aleks Kissinger. All rights reserved. // +// +// This file is part of TikZiT. +// +// TikZiT is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// TikZiT is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with TikZiT. If not, see . +// #import "PreferenceController.h" @@ -19,8 +35,6 @@ self = [super initWithWindow:window]; if (self) { // Initialization code here. - NSLog(@"preference controller is running..."); - NSLog(@"Test defaults: %@",[[NSUserDefaults standardUserDefaults] valueForKey:@"testDefaultsHandler"]); } return self; @@ -87,7 +101,6 @@ NSRect newFrame = [self newFrameForNewContentView:view]; - [NSAnimationContext beginGrouping]; if ([[NSApp currentEvent] modifierFlags] & NSShiftKeyMask) diff --git a/tikzit/src/osx/Preferences.xib b/tikzit/src/osx/Preferences.xib index 7184328..1b2d0c3 100644 --- a/tikzit/src/osx/Preferences.xib +++ b/tikzit/src/osx/Preferences.xib @@ -3,15 +3,17 @@ 1080 12C60 - 2843 + 2840 1187.34 625.00 com.apple.InterfaceBuilder.CocoaPlugin - 2843 + 2840 IBNSLayoutConstraint + NSButton + NSButtonCell NSCustomObject NSCustomView NSTextField @@ -100,7 +102,7 @@ 0 - + @@ -119,7 +121,7 @@ - {{0, 0}, {1600, 1200}} + {{0, 0}, {1680, 1050}} {10000000000000, 10000000000000} YES @@ -127,25 +129,57 @@ 268 - + 268 - {{20, 32}, {96, 22}} + {{18, 15}, {215, 18}} _NS:9 YES - - -1804599231 - 272630784 - + + -2080374784 + 268435456 + Bring preview window to focus LucidaGrande 13 1044 _NS:9 + + 1211912448 + 2 + + NSImage + NSSwitch + + + NSSwitch + + + + 200 + 25 + + NO + + + + 268 + {{20, 39}, {440, 22}} + + + + _NS:9 + YES + + -1804599231 + 272630784 + + + _NS:9 YES @@ -172,7 +206,7 @@ 268 - {{17, 69}, {47, 17}} + {{17, 69}, {142, 17}} @@ -181,7 +215,7 @@ 68157504 272630784 - Engine + pdfLaTeX source path _NS:1535 @@ -300,19 +334,35 @@ - value: values.testDefaultsHandlerOther + value: values.net.sourceforge.tikzit.pdflatexpath - value: values.testDefaultsHandlerOther + value: values.net.sourceforge.tikzit.pdflatexpath + value + values.net.sourceforge.tikzit.pdflatexpath + 2 + + + 54 + + + + value: values.net.sourceforge.tikzit.previewfocus + + + + + + value: values.net.sourceforge.tikzit.previewfocus value - values.testDefaultsHandlerOther + values.net.sourceforge.tikzit.previewfocus 2 - 52 + 62 @@ -378,8 +428,24 @@ 13 - - + + + 3 + 0 + + 4 + 1 + + 8 + + 1000 + + 6 + 24 + 3 + + + 5 0 @@ -394,20 +460,52 @@ 29 3 - + + + 6 + 0 + + 6 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + 3 0 + + 4 + 1 + + 8 + + 1000 + + 6 + 24 + 3 + + + + 5 + 0 - 3 + 5 1 - - 42 + + 20 1000 - 3 - 9 + 8 + 29 3 @@ -444,6 +542,7 @@ + @@ -538,22 +637,6 @@ - - - 7 - 0 - - 0 - 1 - - 96 - - 1000 - - 3 - 9 - 1 - @@ -562,16 +645,6 @@ - - 34 - - - - - 35 - - - 36 @@ -582,6 +655,39 @@ + + 55 + + + + + 56 + + + + + 57 + + + + + + + + 58 + + + + + 59 + + + + + 60 + + + @@ -596,8 +702,11 @@ - + + + + com.apple.InterfaceBuilder.CocoaPlugin @@ -616,23 +725,25 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - - - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin - 52 + 62 @@ -675,10 +786,10 @@ IBCocoaFramework YES 3 - - NSPreferencesGeneral - {32, 32} - + + {32, 32} + {15, 15} + YES diff --git a/tikzit/src/osx/PreviewController.m b/tikzit/src/osx/PreviewController.m index 76c5ced..7c41562 100644 --- a/tikzit/src/osx/PreviewController.m +++ b/tikzit/src/osx/PreviewController.m @@ -45,7 +45,11 @@ static PreviewController *preview = nil; // Only build one tex file at a time, so we don't get funky results. //[latexLock lock]; [progressIndicator startAnimation:self]; - + + if([[NSUserDefaults standardUserDefaults] boolForKey:@"net.sourceforge.tikzit.previewfocus"]){ + [[preview window] makeKeyAndOrderFront:self]; + } + int fnum = typesetCount++; NSString *tex = [NSString stringWithFormat:@"%@%@%@", @@ -57,12 +61,14 @@ static PreviewController *preview = nil; NSString *pdfFile = [NSString stringWithFormat:@"%@/tikzit_%d.pdf", tempDir, fnum]; [tex writeToFile:texFile atomically:NO encoding:NSUTF8StringEncoding error:NULL]; + + NSString *pdflatexPath = [[NSUserDefaults standardUserDefaults] stringForKey:@"net.sourceforge.tikzit.pdflatexpath"]; // We run pdflatex in a bash shell to have easy access to the setup from unix-land NSTask *latexTask = [[NSTask alloc] init]; [latexTask setCurrentDirectoryPath:tempDir]; [latexTask setLaunchPath:@"/bin/bash"]; - + // This assumes the user has $PATH set up to find pdflatex in either .profile // or .bashrc. This should be improved to take other path setups into account // and to be customisable. @@ -70,10 +76,9 @@ static PreviewController *preview = nil; [NSString stringWithFormat: @"if [ -e ~/.profile ]; then source ~/.profile; fi\n" @"if [ -e ~/.bashrc ]; then source ~/.bashrc; fi\n" - @"pdflatex -interaction=nonstopmode -output-format=pdf -halt-on-error '%@'\n", - texFile]; + @"%@ -interaction=nonstopmode -output-format=pdf -halt-on-error '%@'\n", pdflatexPath, texFile]; - //NSLog(@"Telling bash: %@", latexCmd); + NSLog(@"Telling bash: %@", latexCmd); NSPipe *pout = [NSPipe pipe]; NSPipe *pin = [NSPipe pipe]; @@ -94,9 +99,15 @@ static PreviewController *preview = nil; [latexTask waitUntilExit]; if ([latexTask terminationStatus] != 0) { - [errorTextView setHidden:YES]; - [errorText setString:[@"\nAN ERROR HAS OCCURRED, PDFLATEX SAID:\n\n" stringByAppendingString:str]]; - [errorTextView setHidden:NO]; + if ([latexTask terminationStatus] == 127) { + [errorTextView setHidden:YES]; + [errorText setString:@"\nCouldn't find pdflatex, change settings and try again."]; + [errorTextView setHidden:NO]; + }else{ + [errorTextView setHidden:YES]; + [errorText setString:[@"\nAN ERROR HAS OCCURRED, PDFLATEX SAID:\n\n" stringByAppendingString:str]]; + [errorTextView setHidden:NO]; + } } else { [errorText setString:@""]; [errorTextView setHidden:YES]; -- cgit v1.2.3