diff --git a/Resources/installLilypond.scpt b/Resources/installLilypond.scpt new file mode 100644 index 0000000..abbc99c Binary files /dev/null and b/Resources/installLilypond.scpt differ diff --git a/Resources/installPython.scpt b/Resources/installPython.scpt new file mode 100644 index 0000000..5c4a7f7 Binary files /dev/null and b/Resources/installPython.scpt differ 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