diff --git a/extras/Jucer (experimental)/Builds/MacOSX/Info.plist b/extras/Jucer (experimental)/Builds/MacOSX/Info.plist index 7fc21c774e..2dec134871 100644 --- a/extras/Jucer (experimental)/Builds/MacOSX/Info.plist +++ b/extras/Jucer (experimental)/Builds/MacOSX/Info.plist @@ -19,5 +19,20 @@ 3.0.0 CFBundleVersion 3.0.0 + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + jucer + + CFBundleTypeName + jucer + CFBundleTypeRole + Editor + NSPersistentStoreTypeKey + XML + + diff --git a/extras/Jucer (experimental)/Jucer.jucer b/extras/Jucer (experimental)/Jucer.jucer index def35c844d..1abd9efa83 100644 --- a/extras/Jucer (experimental)/Jucer.jucer +++ b/extras/Jucer (experimental)/Jucer.jucer @@ -12,7 +12,7 @@ pluginAUViewClass="TheJucerAU_V1" pluginRTASCategory="" bundleIdentifier="com.rawmaterialsoftware.thejucer"> + juceFolder="../.." documentExtensions=".jucer"/> newDoc (new Project (file)); + + if (! newDoc->loadFrom (file, true)) + { + std::cout << "Failed to load the project file!" << std::endl; + return; + } + + String error (newDoc->saveDocument (file)); + + if (error.isNotEmpty()) + { + std::cout << "Error when writing project: " << error << std::endl; + return; + } + } + void initialise (const String& commandLine) { + /* Running a command-line of the form "Jucer --resave foobar.jucer" will try to load that + jucer file and re-export all of its projects. + */ + if (commandLine.startsWithIgnoreCase (T("-resave ")) || commandLine.startsWithIgnoreCase (T("--resave "))) + { + resaveJucerFile (File::getCurrentWorkingDirectory() + .getChildFile (commandLine.fromFirstOccurrenceOf (T(" "), false, false).unquoted())); + quit(); + return; + } + commandManager = new ApplicationCommandManager(); theMainWindow = new MainWindow(); diff --git a/extras/Jucer (experimental)/Source/model/jucer_ProjectExport_XCode.h b/extras/Jucer (experimental)/Source/model/jucer_ProjectExport_XCode.h index db7d0470c5..5b0b650363 100644 --- a/extras/Jucer (experimental)/Source/model/jucer_ProjectExport_XCode.h +++ b/extras/Jucer (experimental)/Source/model/jucer_ProjectExport_XCode.h @@ -92,6 +92,12 @@ public: props.add (new TextPropertyComponent (getSetting ("objCExtraSuffix"), "Objective-C class name suffix", 64, false)); props.getLast()->setTooltip ("Because objective-C linkage is done by string-matching, you can get horrible linkage mix-ups when different modules containing the " "same class-names are loaded simultaneously. This setting lets you provide a unique string that will be used in naming the obj-C classes in your executable to avoid this."); + + if (! iPhone) + { + props.add (new TextPropertyComponent (getSetting ("documentExtensions"), "Document file extensions", 128, false)); + props.getLast()->setTooltip ("A comma-separated list of file extensions for documents that your app can open."); + } } void launchProject() @@ -233,6 +239,30 @@ private: addPlistDictionaryKey (dict, "CFBundleShortVersionString", project.getVersion().toString()); addPlistDictionaryKey (dict, "CFBundleVersion", project.getVersion().toString()); + StringArray documentExtensions; + documentExtensions.addTokens (getSetting ("documentExtensions").toString(), ",", String::empty); + documentExtensions.trim(); + documentExtensions.removeEmptyStrings (true); + + if (documentExtensions.size() > 0) + { + dict->createNewChildElement ("key")->addTextElement ("CFBundleDocumentTypes"); + XmlElement* dict2 = dict->createNewChildElement ("array")->createNewChildElement ("dict"); + + for (int i = 0; i < documentExtensions.size(); ++i) + { + String ex (documentExtensions[i]); + if (ex.startsWithChar ('.')) + ex = ex.substring (1); + + dict2->createNewChildElement ("key")->addTextElement ("CFBundleTypeExtensions"); + dict2->createNewChildElement ("array")->createNewChildElement ("string")->addTextElement (ex); + addPlistDictionaryKey (dict2, "CFBundleTypeName", ex); + addPlistDictionaryKey (dict2, "CFBundleTypeRole", "Editor"); + addPlistDictionaryKey (dict2, "NSPersistentStoreTypeKey", "XML"); + } + } + MemoryOutputStream mo; plist.writeToStream (mo, ""); diff --git a/extras/Jucer (experimental)/Source/model/jucer_ProjectSaver.h b/extras/Jucer (experimental)/Source/model/jucer_ProjectSaver.h index a3e06ab1af..774ec7a647 100644 --- a/extras/Jucer (experimental)/Source/model/jucer_ProjectSaver.h +++ b/extras/Jucer (experimental)/Source/model/jucer_ProjectSaver.h @@ -479,6 +479,7 @@ private: for (int i = project.getNumExporters(); --i >= 0;) { ScopedPointer exporter (project.createExporter (i)); + std::cout << "Writing files for: " << exporter->getName() << std::endl; const File targetFolder (exporter->getTargetFolder()); diff --git a/extras/Jucer (experimental)/Source/utility/jucer_StoredSettings.cpp b/extras/Jucer (experimental)/Source/utility/jucer_StoredSettings.cpp index 1fbd87a623..2aea4bec46 100644 --- a/extras/Jucer (experimental)/Source/utility/jucer_StoredSettings.cpp +++ b/extras/Jucer (experimental)/Source/utility/jucer_StoredSettings.cpp @@ -37,7 +37,7 @@ StoredSettings::StoredSettings() StoredSettings::~StoredSettings() { flush(); - deleteAndZero (props); + props = 0; clearSingletonInstance(); } @@ -47,6 +47,7 @@ juce_ImplementSingleton (StoredSettings); //============================================================================== PropertiesFile& StoredSettings::getProps() { + jassert (props != 0); return *props; } @@ -58,14 +59,16 @@ void StoredSettings::flush() props->removeValue ("keyMappings"); - ScopedPointer keys (commandManager->getKeyMappings()->createXml (true)); + if (commandManager != 0) + { + ScopedPointer keys (commandManager->getKeyMappings()->createXml (true)); - if (keys != 0) - props->setValue ("keyMappings", (XmlElement*) keys); + if (keys != 0) + props->setValue ("keyMappings", (XmlElement*) keys); + } } - deleteAndZero (props); - + props = 0; props = PropertiesFile::createDefaultAppPropertiesFile ("Jucer2", "settings", String::empty, diff --git a/extras/Jucer (experimental)/Source/utility/jucer_StoredSettings.h b/extras/Jucer (experimental)/Source/utility/jucer_StoredSettings.h index 60a7816124..a49097bb26 100644 --- a/extras/Jucer (experimental)/Source/utility/jucer_StoredSettings.h +++ b/extras/Jucer (experimental)/Source/utility/jucer_StoredSettings.h @@ -57,7 +57,7 @@ public: juce_UseDebuggingNewOperator private: - PropertiesFile* props; + ScopedPointer props; }; diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index b24a5cecf4..f5cbe440df 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -12375,18 +12375,23 @@ StringArray::StringArray (const StringArray& other) { } +StringArray::StringArray (const String& firstValue) +{ + strings.add (firstValue); +} + StringArray::StringArray (const juce_wchar** const initialStrings, const int numberOfStrings) { for (int i = 0; i < numberOfStrings; ++i) - add (initialStrings [i]); + strings.add (initialStrings [i]); } StringArray::StringArray (const char** const initialStrings, const int numberOfStrings) { for (int i = 0; i < numberOfStrings; ++i) - add (initialStrings [i]); + strings.add (initialStrings [i]); } StringArray::StringArray (const juce_wchar** const initialStrings) @@ -12394,7 +12399,7 @@ StringArray::StringArray (const juce_wchar** const initialStrings) int i = 0; while (initialStrings[i] != 0) - add (initialStrings [i++]); + strings.add (initialStrings [i++]); } StringArray::StringArray (const char** const initialStrings) @@ -12402,7 +12407,7 @@ StringArray::StringArray (const char** const initialStrings) int i = 0; while (initialStrings[i] != 0) - add (initialStrings [i++]); + strings.add (initialStrings [i++]); } StringArray& StringArray::operator= (const StringArray& other) @@ -12415,7 +12420,7 @@ StringArray::~StringArray() { } -bool StringArray::operator== (const StringArray& other) const +bool StringArray::operator== (const StringArray& other) const throw() { if (other.size() != size()) return false; @@ -12427,7 +12432,7 @@ bool StringArray::operator== (const StringArray& other) const return true; } -bool StringArray::operator!= (const StringArray& other) const +bool StringArray::operator!= (const StringArray& other) const throw() { return ! operator== (other); } @@ -12780,10 +12785,14 @@ void StringArray::removeDuplicates (const bool ignoreCase) void StringArray::appendNumbersToDuplicates (const bool ignoreCase, const bool appendNumberToFirstInstance, - const juce_wchar* const preNumberString, - const juce_wchar* const postNumberString) + const juce_wchar* preNumberString, + const juce_wchar* postNumberString) { - jassert (preNumberString != 0 && postNumberString != 0); // These strings can't be null pointers.. + if (preNumberString == 0) + preNumberString = T(" ("); + + if (postNumberString == 0) + postNumberString = T(")"); for (int i = 0; i < size() - 1; ++i) { diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 1a4acfb3e7..f473abd8e6 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -3883,6 +3883,8 @@ public: StringArray (const StringArray& other); + explicit StringArray (const String& firstValue); + StringArray (const juce_wchar** strings, int numberOfStrings); StringArray (const char** strings, int numberOfStrings); @@ -3895,9 +3897,9 @@ public: StringArray& operator= (const StringArray& other); - bool operator== (const StringArray& other) const; + bool operator== (const StringArray& other) const throw(); - bool operator!= (const StringArray& other) const; + bool operator!= (const StringArray& other) const throw(); inline int size() const throw() { return strings.size(); }; @@ -3948,8 +3950,8 @@ public: void appendNumbersToDuplicates (bool ignoreCaseWhenComparing, bool appendNumberToFirstInstance, - const juce_wchar* preNumberString = JUCE_T(" ("), - const juce_wchar* postNumberString = JUCE_T(")")); + const juce_wchar* preNumberString = 0, + const juce_wchar* postNumberString = 0); const String joinIntoString (const String& separatorString, int startIndex = 0, diff --git a/src/text/juce_StringArray.cpp b/src/text/juce_StringArray.cpp index 32c85557d4..39f5139fdd 100644 --- a/src/text/juce_StringArray.cpp +++ b/src/text/juce_StringArray.cpp @@ -41,18 +41,23 @@ StringArray::StringArray (const StringArray& other) { } +StringArray::StringArray (const String& firstValue) +{ + strings.add (firstValue); +} + StringArray::StringArray (const juce_wchar** const initialStrings, const int numberOfStrings) { for (int i = 0; i < numberOfStrings; ++i) - add (initialStrings [i]); + strings.add (initialStrings [i]); } StringArray::StringArray (const char** const initialStrings, const int numberOfStrings) { for (int i = 0; i < numberOfStrings; ++i) - add (initialStrings [i]); + strings.add (initialStrings [i]); } StringArray::StringArray (const juce_wchar** const initialStrings) @@ -60,7 +65,7 @@ StringArray::StringArray (const juce_wchar** const initialStrings) int i = 0; while (initialStrings[i] != 0) - add (initialStrings [i++]); + strings.add (initialStrings [i++]); } StringArray::StringArray (const char** const initialStrings) @@ -68,7 +73,7 @@ StringArray::StringArray (const char** const initialStrings) int i = 0; while (initialStrings[i] != 0) - add (initialStrings [i++]); + strings.add (initialStrings [i++]); } StringArray& StringArray::operator= (const StringArray& other) @@ -81,7 +86,7 @@ StringArray::~StringArray() { } -bool StringArray::operator== (const StringArray& other) const +bool StringArray::operator== (const StringArray& other) const throw() { if (other.size() != size()) return false; @@ -93,7 +98,7 @@ bool StringArray::operator== (const StringArray& other) const return true; } -bool StringArray::operator!= (const StringArray& other) const +bool StringArray::operator!= (const StringArray& other) const throw() { return ! operator== (other); } diff --git a/src/text/juce_StringArray.h b/src/text/juce_StringArray.h index 7e1461a1e0..bbed3f84ff 100644 --- a/src/text/juce_StringArray.h +++ b/src/text/juce_StringArray.h @@ -46,8 +46,10 @@ public: /** Creates a copy of another string array */ StringArray (const StringArray& other); - /** Creates a copy of an array of string literals. + /** Creates an array containing a single string. */ + explicit StringArray (const String& firstValue); + /** Creates a copy of an array of string literals. @param strings an array of strings to add. Null pointers in the array will be treated as empty strings @param numberOfStrings how many items there are in the array @@ -55,7 +57,6 @@ public: StringArray (const juce_wchar** strings, int numberOfStrings); /** Creates a copy of an array of string literals. - @param strings an array of strings to add. Null pointers in the array will be treated as empty strings @param numberOfStrings how many items there are in the array @@ -63,7 +64,6 @@ public: StringArray (const char** strings, int numberOfStrings); /** Creates a copy of a null-terminated array of string literals. - Each item from the array passed-in is added, until it encounters a null pointer, at which point it stops. */ @@ -84,20 +84,16 @@ public: //============================================================================== /** Compares two arrays. - Comparisons are case-sensitive. - @returns true only if the other array contains exactly the same strings in the same order */ - bool operator== (const StringArray& other) const; + bool operator== (const StringArray& other) const throw(); /** Compares two arrays. - Comparisons are case-sensitive. - @returns false if the other array contains exactly the same strings in the same order */ - bool operator!= (const StringArray& other) const; + bool operator!= (const StringArray& other) const throw(); //============================================================================== /** Returns the number of strings in the array */