From 3096164028fce540033527ad2cb93a776e4077da Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Mon, 23 Apr 2007 03:43:39 +0000 Subject: [PATCH] Prompt for installation of missing pieces --- Resources/installLilypond.scpt | Bin 0 -> 1066 bytes Resources/installPython.scpt | Bin 0 -> 1032 bytes Sources/VLAppController.mm | 87 ++++++++++++++++++++++++++++- Vocalese.xcodeproj/project.pbxproj | 8 +++ mma/mma.py | 2 +- 5 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 Resources/installLilypond.scpt create mode 100644 Resources/installPython.scpt diff --git a/Resources/installLilypond.scpt b/Resources/installLilypond.scpt new file mode 100644 index 0000000000000000000000000000000000000000..abbc99c92c3dd59b2431baa2a12830114cd33dd5 GIT binary patch literal 1066 zcmb_b%}x_h6#iyfDIGd9ZDB!Nk(juEq|k;9RTCS3q6rBL+r;g4rX~Z^&ZIMtu;UTf z`vPu^_zJ{@&tM`kJ^=C~BEQG)7DXVzxbRNyx#v6Q%sqeiJXVR{YCIdOR;p8aI{>n- z2n?9W7-V3R&xC|P5m`Bv6B}8WbHrM50|PdRu|SlCi=2rZjR%ppNit8#XOWjMBtf3rk^>vo*%cOC`GFzXw|I47fJz?nm^N{$Q1_%Nsg`v2=b9jGu!^v%XR%VQK~+fl4~ z{!C-KTD#(K{lUkHClh_)TA|tQb%L%6D=Ln!*!>&4_jT}+<4n7rfy!!RcKpct&2YH|WN z3>Iz?8D!);-4qQTOwy%#&yqd9NY!3SBi2_xWMG9Eu40_ap;@jd-%yfW*!HRX}i&LfVA7XizYCL7~uv3Ai1Th|^9oLuM?v>mzjU z3%C*MD+CulgJ2OKp!Q;|O)tmqpK56f6&L=)e=h$ybMEJ%8+BTZC#7noI;*Y?AmxZa zgAPL@0gJTZlLc}}$%!0WNI_pDuU@WU%p%a1$)(^Rts_n4abzq4<1y(JGIAt`GBV`| zQRhXg+w_v@ij!#|M){)752|R%5gs5@`py19nO5xiUhH)lVvdc)@c!-B6y_7U zcJni7P0?8Aea8%D&nHlCgrV=X-PjBIQT@zT{X+0IuCrrJbTL3L>5}SDg?$S7If-}EMiqK{_E(}&q6gUQK1`8(#1BU#do18|(Bpr(P zOxfeSx!sjGV13n?0;|k$4P_piYU!MOM_zVihd~r&+a!DS9~LW??27U*sbf<0TDElA zQqkeVr2^DkSGmu=*~6kwH?xDbn935}KmH);>qGi$W5 G@%9&VM&>L4 literal 0 HcmV?d00001 diff --git a/Sources/VLAppController.mm b/Sources/VLAppController.mm index cfbfd6a..a6c7e1a 100644 --- a/Sources/VLAppController.mm +++ b/Sources/VLAppController.mm @@ -97,6 +97,11 @@ return [self getLineFromCommand:cmd]; } +- (void)adviseLilypondInstallation:(id)sender +{ +// [NSApp terminate:self]; +} + - (void)awakeFromNib { [lilypondPath setAutoenablesItems:NO]; @@ -168,7 +173,87 @@ wantTool = true; [defaults setObject:toolPath forKey:@"VLLilypondPath"]; } - [lilypondPath selectItemWithTag:wantTool ? 0 : 1]; + [lilypondPath selectItemWithTag:wantTool ? 0 : 1]; +} + +- (BOOL)promptForSoftwareInstallation:(NSString *)label + withTitle:(NSString *)title + explanation:(NSString *)expl + script:(NSString *)script + url:(NSURL *)url +{ + NSString * hasFink = [self getLineFromCommand:@"bash -l which fink"]; + + NSInteger response = + [[NSAlert alertWithMessageText:title + defaultButton: hasFink + ? @"Install through fink" + : label + alternateButton:@"Continue" + otherButton:hasFink + ? label + : @"" + informativeTextWithFormat: expl, hasFink + ? @"\n\nSince you have fink installed already, you may " + "choose to install this package through fink." : @""] + runModal]; + + if (response == NSAlertAlternateReturn) + return NO; + else if (hasFink && response == NSAlertDefaultReturn) { + NSDictionary * error; + NSURL * scptURL = + [NSURL fileURLWithPath: + [[NSBundle mainBundle] pathForResource:script + ofType:@"scpt"]]; + NSAppleScript * scpt = + [[NSAppleScript alloc] + initWithContentsOfURL:scptURL error:&error]; + [scpt executeAndReturnError:&error]; + } else { + [[NSWorkspace sharedWorkspace] openURL:url]; + } + return YES; +} + +- (void)applicationWillFinishLaunching:(NSNotification *)aNotification +{ + BOOL quit = NO; + + if (!toolPath && !appPath) + if ([self promptForSoftwareInstallation:@"Download from lilypond.org" + withTitle: @"Lilypond Not Found!" + explanation: + @"Couldn't find an installation of Lilypond, which " + "is needed to typeset the sheet music. If you continue " + "without installing, you will be unable to preview, " + "print, or save as PDF.%@" + script:@"installLilypond" + url:[NSURL URLWithString:@"http://lilypond.org/web/install"]] + ) + quit = YES; + if (![self getLineFromCommand:@"bash -l which python2.5"]) + if ([self promptForSoftwareInstallation:@"Download from python.org" + withTitle: @"Python 2.5 Not Found!" + explanation: + @"Python 2.5 is needed to play accompaniments. The " + "version preinstalled on your computer is not recent " + "enough. If you continue without installing, you will be " + "unable to play accompaniments, or save as MIDI.%@" + script:@"installPython" + url:[NSURL URLWithString:@"http://www.python.org/download"]] + ) + quit = YES; + + if (quit) { + [[NSAlert alertWithMessageText:@"Quit and Restart" + defaultButton: @"OK" alternateButton: @"" otherButton: @"" + informativeTextWithFormat: + @"The software you have chosen to install will be " + "available after you restart this application."] + runModal]; + [NSApp terminate:self]; + } } - (IBAction) playNewPitch:(id)sender diff --git a/Vocalese.xcodeproj/project.pbxproj b/Vocalese.xcodeproj/project.pbxproj index 3f56d60..112e4e3 100644 --- a/Vocalese.xcodeproj/project.pbxproj +++ b/Vocalese.xcodeproj/project.pbxproj @@ -21,6 +21,8 @@ 95009B800B0EDC7B00EB33A4 /* CADebugMacros.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95009B4E0B0ED0BB00EB33A4 /* CADebugMacros.cpp */; }; 95009B810B0EDC7D00EB33A4 /* CAStreamBasicDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95009B260B0ECF9000EB33A4 /* CAStreamBasicDescription.cpp */; }; 95009B830B0EDCD800EB33A4 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 95009B820B0EDCD800EB33A4 /* CoreFoundation.framework */; }; + 95049CF30BDC32EB0015EE6E /* installLilypond.scpt in Resources */ = {isa = PBXBuildFile; fileRef = 95049CF20BDC32CD0015EE6E /* installLilypond.scpt */; }; + 95049D020BDC436A0015EE6E /* installPython.scpt in Resources */ = {isa = PBXBuildFile; fileRef = 95049D010BDC43510015EE6E /* installPython.scpt */; }; 950795E10B4A34D9008911A6 /* stop.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 950795E00B4A34D9008911A6 /* stop.tiff */; }; 952CBB9C095FD1CA00434E43 /* VLSoundOut.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 952CBB9A095FD1CA00434E43 /* VLSoundOut.cpp */; }; 952CBB9D095FD1CA00434E43 /* VLSoundOut.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 952CBB9A095FD1CA00434E43 /* VLSoundOut.cpp */; }; @@ -144,6 +146,8 @@ 95009B620B0ED18700EB33A4 /* CAConditionalMacros.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CAConditionalMacros.h; path = Sources/CoreAudioSDK/CAConditionalMacros.h; sourceTree = ""; }; 95009B630B0ED18700EB33A4 /* CAMath.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CAMath.h; path = Sources/CoreAudioSDK/CAMath.h; sourceTree = ""; }; 95009B820B0EDCD800EB33A4 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = ""; }; + 95049CF20BDC32CD0015EE6E /* installLilypond.scpt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.scpt; name = installLilypond.scpt; path = Resources/installLilypond.scpt; sourceTree = ""; }; + 95049D010BDC43510015EE6E /* installPython.scpt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.scpt; name = installPython.scpt; path = Resources/installPython.scpt; sourceTree = ""; }; 950795E00B4A34D9008911A6 /* stop.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = stop.tiff; path = Resources/stop.tiff; sourceTree = ""; }; 952CBB98095FD19D00434E43 /* TVLSoundOut */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TVLSoundOut; sourceTree = BUILT_PRODUCTS_DIR; }; 952CBB9A095FD1CA00434E43 /* VLSoundOut.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = VLSoundOut.cpp; path = Sources/VLSoundOut.cpp; sourceTree = ""; }; @@ -387,6 +391,8 @@ 2A37F4B8FDCFA73011CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + 95049CF20BDC32CD0015EE6E /* installLilypond.scpt */, + 95049D010BDC43510015EE6E /* installPython.scpt */, 954DD4DF0B44E61E0056C504 /* VLDocument.nib */, 954DD4DA0B44E6000056C504 /* MainMenu.nib */, 95FC66BC0AF0A4D4003D9C11 /* console.icns */, @@ -586,6 +592,8 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 95049D020BDC436A0015EE6E /* installPython.scpt in Resources */, + 95049CF30BDC32EB0015EE6E /* installLilypond.scpt in Resources */, 8D15AC2C0486D014006FF6A4 /* Credits.rtf in Resources */, 8D15AC2F0486D014006FF6A4 /* InfoPlist.strings in Resources */, 95B3E1A70960E58B000E9C0D /* Music in Resources */, diff --git a/mma/mma.py b/mma/mma.py index cabd499..a2425e4 100755 --- a/mma/mma.py +++ b/mma/mma.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.5 """ The program "MMA - Musical Midi Accompaniment" and the associated