Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moving code over to functionalkit from motive.

  • Loading branch information...
commit 4a8c36c6f6fdf5d88664f7313439799bf0de53dc 1 parent 16cb8b3
Tom Adams tomjadams authored
Showing with 26,876 additions and 0 deletions.
  1. +14 −0 .gitignore
  2. +202 −0 LICENCE
  3. +32 −0 NOTICE
  4. +4 −0 README
  5. +35 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMDelegatingTableColumn.h
  6. +42 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMDelegatingTableColumn.m
  7. +76 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMLinearRGBShading.h
  8. +203 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMLinearRGBShading.m
  9. +95 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMLinearRGBShadingTest.m
  10. +87 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMLoginItems.h
  11. +184 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMLoginItems.m
  12. +112 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMLoginItemsTest.m
  13. +33 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+CGPath.h
  14. +69 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+CGPath.m
  15. +76 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+CGPathTest.m
  16. +48 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+RoundRect.h
  17. +68 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+RoundRect.m
  18. +98 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+RoundRectTest.m
  19. +121 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+Shading.h
  20. +220 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+Shading.m
  21. +95 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+ShadingTest.m
  22. +33 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSWorkspace+ScreenSaver.h
  23. +132 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSWorkspace+ScreenSaver.m
  24. +33 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSWorkspace+ScreenSaverTest.m
  25. +41 −0 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMShading.h
  26. BIN  Source/External/google-toolbox-for-mac-1-5-1/AppKit/TestData/GTMNSBezierPath+CGPathTest.ppc64.tiff
  27. BIN  Source/External/google-toolbox-for-mac-1-5-1/AppKit/TestData/GTMNSBezierPath+CGPathTest.tiff
  28. BIN  Source/External/google-toolbox-for-mac-1-5-1/AppKit/TestData/GTMNSBezierPath+CGPathTest.x86_64.tiff
  29. BIN  Source/External/google-toolbox-for-mac-1-5-1/AppKit/TestData/GTMNSBezierPath+RoundRectTest.ppc64.tiff
  30. BIN  Source/External/google-toolbox-for-mac-1-5-1/AppKit/TestData/GTMNSBezierPath+RoundRectTest.tiff
  31. BIN  Source/External/google-toolbox-for-mac-1-5-1/AppKit/TestData/GTMNSBezierPath+RoundRectTest.x86_64.tiff
  32. BIN  Source/External/google-toolbox-for-mac-1-5-1/AppKit/TestData/GTMNSBezierPath+ShadingTest.10.5.tiff
  33. +54 −0 Source/External/google-toolbox-for-mac-1-5-1/BuildScripts/BuildAllSDKs.sh
  34. +18 −0 Source/External/google-toolbox-for-mac-1-5-1/BuildingAndUsing.txt
  35. +202 −0 Source/External/google-toolbox-for-mac-1-5-1/COPYING
  36. +100 −0 Source/External/google-toolbox-for-mac-1-5-1/DebugUtils/GTMDebugSelectorValidation.h
  37. +34 −0 Source/External/google-toolbox-for-mac-1-5-1/DebugUtils/GTMDevLog.m
  38. +88 −0 Source/External/google-toolbox-for-mac-1-5-1/DebugUtils/GTMMethodCheck.h
  39. +161 −0 Source/External/google-toolbox-for-mac-1-5-1/DebugUtils/GTMMethodCheck.m
  40. +49 −0 Source/External/google-toolbox-for-mac-1-5-1/DebugUtils/GTMMethodCheckTest.m
  41. +183 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMBase64.h
  42. +697 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMBase64.m
  43. +437 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMBase64Test.m
  44. +102 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMCalculatedRange.h
  45. +151 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMCalculatedRange.m
  46. +101 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMCalculatedRangeTest.m
  47. +51 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMFourCharCode.h
  48. +98 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMFourCharCode.m
  49. +82 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMFourCharCodeTest.m
  50. +43 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMGarbageCollection.h
  51. +432 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMGeometryUtils.h
  52. +104 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMGeometryUtils.m
  53. +197 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMGeometryUtilsTest.m
  54. +500 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMHTTPFetcher.h
  55. +1,890 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMHTTPFetcher.m
  56. +463 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMHTTPFetcherTest.m
  57. +133 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMHTTPServer.h
  58. +584 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMHTTPServer.m
  59. +573 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMHTTPServerTest.m
  60. +39 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSAppleEvent+HandlerTest.applescript
  61. +91 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSAppleEventDescriptor+Foundation.h
  62. +488 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSAppleEventDescriptor+Foundation.m
  63. +619 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSAppleEventDescriptor+FoundationTest.m
  64. +40 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSAppleEventDescriptor+Handler.h
  65. +130 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSAppleEventDescriptor+Handler.m
  66. +70 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSAppleEventDescriptor+HandlerTest.m
  67. +59 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSAppleScript+Handler.h
  68. +283 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSAppleScript+Handler.m
  69. +331 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSAppleScript+HandlerTest.m
  70. +84 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSData+zlib.h
  71. +267 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSData+zlib.m
  72. +350 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSData+zlibTest.m
  73. +30 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSDictionary+URLArguments.h
  74. +40 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSDictionary+URLArguments.m
  75. +54 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSDictionary+URLArgumentsTest.m
  76. +53 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSEnumerator+Filter.h
  77. +179 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSEnumerator+Filter.m
  78. +133 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSEnumerator+FilterTest.m
  79. +72 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSFileManager+Path.h
  80. +102 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSFileManager+Path.m
  81. +249 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSFileManager+PathTest.m
  82. +66 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSString+HTML.h
  83. +522 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSString+HTML.m
  84. +242 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSString+HTMLTest.m
  85. +41 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSString+URLArguments.h
  86. +45 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSString+URLArguments.m
  87. +94 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSString+URLArgumentsTest.m
  88. +51 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSString+XML.h
  89. +182 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSString+XML.m
  90. +93 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMNSString+XMLTest.m
  91. +66 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMObjC2Runtime.h
  92. +148 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMObjC2Runtime.m
  93. +385 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMObjC2RuntimeTest.m
  94. +71 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMObjectSingleton.h
  95. +73 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMProgressMonitorInputStream.h
  96. +187 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMProgressMonitorInputStream.m
  97. +381 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMRegex.h
  98. +812 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMRegex.m
  99. +1,245 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMRegexTest.m
  100. +134 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMScriptRunner.h
  101. +253 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMScriptRunner.m
  102. +415 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMScriptRunnerTest.m
  103. +92 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMStackTrace.c
  104. +82 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMStackTrace.h
  105. +80 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMStackTraceTest.m
  106. +48 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMSystemVersion.h
  107. +123 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMSystemVersion.m
  108. +53 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/GTMSystemVersionTest.m
  109. +9 −0 Source/External/google-toolbox-for-mac-1-5-1/Foundation/TestData/GTMHTTPFetcherTestPage.html
  110. +20 −0 Source/External/google-toolbox-for-mac-1-5-1/GTM-Info.plist
  111. +1,929 −0 Source/External/google-toolbox-for-mac-1-5-1/GTM.xcodeproj/project.pbxproj
  112. +166 −0 Source/External/google-toolbox-for-mac-1-5-1/GTMDefines.h
  113. +36 −0 Source/External/google-toolbox-for-mac-1-5-1/GTM_Prefix.pch
  114. +24 −0 Source/External/google-toolbox-for-mac-1-5-1/GTMiPhone-Info.plist
  115. +534 −0 Source/External/google-toolbox-for-mac-1-5-1/GTMiPhone.xcodeproj/project.pbxproj
  116. +140 −0 Source/External/google-toolbox-for-mac-1-5-1/ReleaseNotes.txt
  117. BIN  Source/External/google-toolbox-for-mac-1-5-1/TigerGcov/libgcov.a
  118. +11 −0 Source/External/google-toolbox-for-mac-1-5-1/TigerGcov/libgcov_readme.html
  119. +20 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTest-Info.plist
  120. +144 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMAppKit+UnitTesting.h
  121. +338 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMAppKit+UnitTesting.m
  122. +46 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMCALayer+UnitTesting.h
  123. +89 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMCALayer+UnitTesting.m
  124. +29 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMIPhoneUnitTestDelegate.h
  125. +160 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMIPhoneUnitTestDelegate.m
  126. +33 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMIPhoneUnitTestMain.m
  127. +103 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMNSObject+BindingUnitTesting.h
  128. +443 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMNSObject+BindingUnitTesting.m
  129. +421 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMNSObject+UnitTesting.h
  130. +1,030 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMNSObject+UnitTesting.m
  131. +1,004 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMSenTestCase.h
  132. +211 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMSenTestCase.m
  133. +39 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMTestHTTPServer.h
  134. +166 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMTestHTTPServer.m
  135. +128 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMUIKit+UnitTesting.h
  136. +118 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMUIKit+UnitTesting.m
  137. +58 −0 Source/External/google-toolbox-for-mac-1-5-1/UnitTesting/GTMUIKit+UnitTestingTest.m
Sorry, we could not display the entire diff because it was too big.
14 .gitignore
View
@@ -0,0 +1,14 @@
+# xcode noise
+build/**
+*.pbxuser
+*.perspectivev3
+*.mode1v3
+
+# old skool
+.svn
+.cvs
+
+# osx noise
+.DS_Store
+#profile
+
202 LICENCE
View
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
32 NOTICE
View
@@ -0,0 +1,32 @@
+Functional Kit Licence Notices
+
+This product includes software developed by the following projects, companies
+or individuals.
+
+
+* ActorKit *
+
+Copyright (c) 2008 Plausible Labs Cooperative, Inc.
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
4 README
View
@@ -0,0 +1,4 @@
+Functional APIs for Objective-C.
+
+Functional Kit is modelled loosely after Functional Java.
+
35 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMDelegatingTableColumn.h
View
@@ -0,0 +1,35 @@
+//
+// GTMDelegatingTableColumn.h
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <Cocoa/Cocoa.h>
+#import "GTMDefines.h"
+
+// NOTE: If you're using the 10.5 SDK, just use the new delegate method:
+// tableView:dataCellForTableColumn:row:
+
+@interface GTMDelegatingTableColumn : NSTableColumn
+// no instance state or new method, it will just invoke the tableview's delegate
+// w/ the method below.
+@end
+
+// the method delegated to
+@interface NSObject (GTMDelegatingTableColumnDelegate)
+- (id)gtm_tableView:(NSTableView *)tableView
+ dataCellForTableColumn:(NSTableColumn *)tableColumn
+ row:(NSInteger)row;
+@end
42 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMDelegatingTableColumn.m
View
@@ -0,0 +1,42 @@
+//
+// GTMDelegatingTableColumn.m
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import "GTMDelegatingTableColumn.h"
+
+@implementation GTMDelegatingTableColumn
+- (id)dataCellForRow:(NSInteger)row {
+ id dataCell = nil;
+ id delegate = [[self tableView] delegate];
+ BOOL sendSuper = YES;
+ if (delegate) {
+ if ([delegate respondsToSelector:@selector(gtm_tableView:dataCellForTableColumn:row:)]) {
+
+ dataCell = [delegate gtm_tableView:[self tableView]
+ dataCellForTableColumn:self
+ row:row];
+ sendSuper = NO;
+ } else {
+ _GTMDevLog(@"tableView delegate didn't implement gtm_tableView:dataCellForTableColumn:row:");
+ }
+ }
+ if (sendSuper) {
+ dataCell = [super dataCellForRow:row];
+ }
+ return dataCell;
+}
+@end
76 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMLinearRGBShading.h
View
@@ -0,0 +1,76 @@
+//
+// GTMLinearRGBShading.h
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <Cocoa/Cocoa.h>
+#import "GTMShading.h"
+#import "GTMCalculatedRange.h"
+
+/// A shading that does returns smooth linear values for RGB.
+//
+/// Thus if you create a shading from 0.0->red to 1.0->blue you will get
+/// \verbatim
+/// - 0.5->purple
+/// - 0.75->eggplant
+/// - 0.25->magenta
+/// \endverbatim
+
+@interface GTMLinearRGBShading : GTMCalculatedRange <GTMShading> {
+@private
+ CGFunctionRef function_; // function used to calculated shading (STRONG)
+ CGColorSpaceRef colorSpace_; // colorspace used for shading (STRONG)
+ BOOL isCalibrated_; // are we using calibrated or device RGB.
+ CGFloat colorValue_[4]; // the RGBA color values
+}
+
+/// Generate a shading with color |begin| at position 0.0 and color |end| at 1.0.
+//
+// Args:
+// begin: color at beginning of range
+// end: color at end of range
+// colorSpaceName: name of colorspace to draw into must be either
+// NSCalibratedRGBColorSpace or NSDeviceRGBColorSpace
+//
+// Returns:
+// a GTMLinearRGBShading
++ (id)shadingFromColor:(NSColor *)begin toColor:(NSColor *)end
+ fromSpaceNamed:(NSString*)colorSpaceName;
+
+/// Generate a shading with a collection of colors at various positions.
+//
+// Args:
+// colors: a C style array containg the colors we are adding
+// colorSpaceName: name of colorspace to draw into must be either
+// NSCalibratedRGBColorSpace or NSDeviceRGBColorSpace
+// positions: a C style array containg the positions we want to
+// add the colors at
+// numberOfColors: how many colors/positions we are adding
+//
+// Returns:
+// a GTMLinearRGBShading
++ (id)shadingWithColors:(NSColor **)colors
+ fromSpaceNamed:(NSString*)colorSpaceName
+ atPositions:(CGFloat *)positions
+ count:(NSUInteger)numberOfColors;
+
+/// Designated initializer
+// Args:
+// colorSpaceName - name of the colorspace to use must be either
+// NSCalibratedRGBColorSpace or NSDeviceRGBColorSpace
+- (id)initWithColorSpaceName:(NSString*)colorSpaceName;
+
+@end
203 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMLinearRGBShading.m
View
@@ -0,0 +1,203 @@
+//
+// GTMLinearRGBShading.m
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import "GTMLinearRGBShading.h"
+
+// Carbon callback function required for CoreGraphics
+static void cShadeFunction(void *info, const CGFloat *inPos, CGFloat *outVals);
+
+@implementation GTMLinearRGBShading
++ (id)shadingFromColor:(NSColor *)begin toColor:(NSColor *)end
+ fromSpaceNamed:(NSString*)colorSpaceName {
+ NSColor *theColors[] = { begin, end };
+ CGFloat thePositions[] = { 0.0, 1.0 };
+ return [[self class] shadingWithColors:theColors
+ fromSpaceNamed:colorSpaceName
+ atPositions:thePositions
+ count:(sizeof(thePositions)/sizeof(CGFloat))];
+}
+
++ (id)shadingWithColors:(NSColor **)colors fromSpaceNamed:(NSString*)colorSpaceName
+ atPositions:(CGFloat *)positions count:(NSUInteger)count {
+
+ GTMLinearRGBShading *theShading = [[[[self class] alloc] initWithColorSpaceName:colorSpaceName] autorelease];
+ for (NSUInteger i = 0; i < count; ++i) {
+ [theShading insertStop:colors[i] atPosition:positions[i]];
+ }
+ return theShading;
+}
+
+- (id)initWithColorSpaceName:(NSString*)colorSpaceName {
+ if ((self = [super init])) {
+ if ([colorSpaceName isEqualToString:NSDeviceRGBColorSpace]) {
+ isCalibrated_ = NO;
+ } else if ([colorSpaceName isEqualToString:NSCalibratedRGBColorSpace]) {
+ isCalibrated_ = YES;
+ }
+ else {
+ [self release];
+ self = nil;
+ }
+ }
+ return self;
+}
+
+- (void)finalize {
+ if (nil != function_) {
+ CGFunctionRelease(function_);
+ }
+ if (nil != colorSpace_) {
+ CGColorSpaceRelease(colorSpace_);
+ }
+ [super finalize];
+}
+
+- (void)dealloc {
+ if (nil != function_) {
+ CGFunctionRelease(function_);
+ }
+ if (nil != colorSpace_) {
+ CGColorSpaceRelease(colorSpace_);
+ }
+ [super dealloc];
+}
+
+
+- (void)insertStop:(id)item atPosition:(CGFloat)position {
+ NSString *colorSpaceName = isCalibrated_ ? NSCalibratedRGBColorSpace : NSDeviceRGBColorSpace;
+ NSColor *tempColor = [item colorUsingColorSpaceName: colorSpaceName];
+ if (nil != tempColor) {
+ [super insertStop:tempColor atPosition:position];
+ }
+}
+
+// Calculate a linear value based on our stops
+- (id)valueAtPosition:(CGFloat)position {
+ NSUInteger positionIndex = 0;
+ NSUInteger colorCount = [self stopCount];
+ CGFloat stop1Position = 0.0;
+ NSColor *stop1Color = [self stopAtIndex:positionIndex position:&stop1Position];
+ positionIndex += 1;
+ CGFloat stop2Position = 0.0;
+ NSColor *stop2Color = nil;
+ NSColor *theColor = nil;
+ if (colorCount > 1) {
+ stop2Color = [self stopAtIndex:positionIndex position:&stop2Position];
+ positionIndex += 1;
+ } else {
+ // if we only have one value, that's what we return
+ stop2Position = stop1Position;
+ stop2Color = stop1Color;
+ }
+
+ while (positionIndex < colorCount && stop2Position < position) {
+ stop1Color = stop2Color;
+ stop1Position = stop2Position;
+ stop2Color = [self stopAtIndex:positionIndex position:&stop2Position];
+ positionIndex += 1;
+ }
+
+ if (position <= stop1Position) {
+ // if we are less than our lowest position, return our first color
+ theColor = stop1Color;
+ [stop1Color getRed:&colorValue_[0] green:&colorValue_[1]
+ blue:&colorValue_[2] alpha:&colorValue_[3]];
+ } else if (position >= stop2Position) {
+ // likewise if we are greater than our highest position, return the last color
+ [stop2Color getRed:&colorValue_[0] green:&colorValue_[1]
+ blue:&colorValue_[2] alpha:&colorValue_[3]];
+ } else {
+ // otherwise interpolate between the two
+ position = (position - stop1Position) / (stop2Position - stop1Position);
+ CGFloat red1, red2, green1, green2, blue1, blue2, alpha1, alpha2;
+ [stop1Color getRed:&red1 green:&green1 blue:&blue1 alpha:&alpha1];
+ [stop2Color getRed:&red2 green:&green2 blue:&blue2 alpha:&alpha2];
+
+ colorValue_[0] = (red2 - red1) * position + red1;
+ colorValue_[1] = (green2 - green1) * position + green1;
+ colorValue_[2] = (blue2 - blue1) * position + blue1;
+ colorValue_[3] = (alpha2 - alpha1) * position + alpha1;
+ }
+
+ // Yes, I am casting a CGFloat[] to an id to pass it by the compiler. This
+ // significantly improves performance though as I avoid creating an NSColor
+ // for every scanline which later has to be cleaned up in an autorelease pool
+ // somewhere. Causes guardmalloc to run significantly faster.
+ return (id)colorValue_;
+}
+
+//
+// switch from C to obj-C. The callback to a shader is a c function
+// but we want to call our objective c object to do all the
+// calculations for us. We have passed our function our
+// GTMLinearRGBShading as an obj-c object in the |info| so
+// we just turn around and ask it to calculate our value based
+// on |inPos| and then stick the results back in |outVals|
+//
+// Args:
+// info: is the GTMLinearRGBShading as an
+// obj-C object.
+// inPos: the position to calculate values for. This is a pointer to
+// a single float value
+// outVals: where we store our return values. Since we are calculating
+// an RGBA color, this is a pointer to an array of four float values
+// ranging from 0.0 to 1.0
+//
+//
+static void cShadeFunction(void *info, const CGFloat *inPos, CGFloat *outVals) {
+ id object = (id)info;
+ CGFloat *colorValue = (CGFloat*)[object valueAtPosition:*inPos];
+ outVals[0] = colorValue[0];
+ outVals[1] = colorValue[1];
+ outVals[2] = colorValue[2];
+ outVals[3] = colorValue[3];
+}
+
+- (CGFunctionRef) shadeFunction {
+ // lazily create the function as necessary
+ if (nil == function_) {
+ // We have to go to carbon here, and create the CGFunction. Note that this
+ // diposed if necessary in the dealloc call.
+ const CGFunctionCallbacks shadeFunctionCallbacks = { 0, &cShadeFunction, NULL };
+
+ // TODO: this code assumes that we have a range from 0.0 to 1.0
+ // which may not be true according to the stops that the user has given us.
+ // In general you have stops at 0.0 and 1.0, so this will do for right now
+ // but may be an issue in the future.
+ const CGFloat inRange[2] = { 0.0, 1.0 };
+ const CGFloat outRange[8] = { 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 };
+ function_ = CGFunctionCreate(self,
+ sizeof(inRange) / (sizeof(CGFloat) * 2), inRange,
+ sizeof(outRange) / (sizeof(CGFloat) * 2), outRange,
+ &shadeFunctionCallbacks);
+ }
+ return function_;
+}
+
+- (CGColorSpaceRef)colorSpace {
+ // lazily create the colorspace as necessary
+ if (nil == colorSpace_) {
+ if (isCalibrated_) {
+ colorSpace_ = CGColorSpaceCreateWithName(kCGColorSpaceUserRGB);
+ } else {
+ colorSpace_ = CGColorSpaceCreateDeviceRGB();
+ }
+ }
+ return colorSpace_;
+}
+@end
95 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMLinearRGBShadingTest.m
View
@@ -0,0 +1,95 @@
+//
+// GTMLinearRGBShadingTest.m
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <SenTestingKit/SenTestingKit.h>
+#import "GTMSenTestCase.h"
+#import "GTMLinearRGBShading.h"
+
+@interface GTMLinearRGBShadingTest : GTMTestCase
+@end
+
+@implementation GTMLinearRGBShadingTest
+- (void)testShadingFrom {
+ // Create a shading from red to blue, and check if 50% is purple
+ NSColor *red = [NSColor redColor];
+ NSColor *blue = [NSColor blueColor];
+ NSColor *purple = [NSColor purpleColor];
+ GTMLinearRGBShading *theShading =
+ [GTMLinearRGBShading shadingFromColor:red
+ toColor:blue
+ fromSpaceNamed:NSCalibratedRGBColorSpace];
+ STAssertNotNil(theShading,nil);
+ STAssertEquals([theShading stopCount], (NSUInteger)2, nil);
+ CGFloat *theColor = (CGFloat*)[theShading valueAtPosition: 0.5];
+ STAssertEqualsWithAccuracy(theColor[0], [purple redComponent], 0.001, nil);
+ STAssertEqualsWithAccuracy(theColor[1], [purple greenComponent], 0.001, nil);
+ STAssertEqualsWithAccuracy(theColor[2], [purple blueComponent], 0.001, nil);
+ STAssertEqualsWithAccuracy(theColor[3], [purple alphaComponent], 0.001, nil);
+}
+
+- (void)testShadingWith {
+ // Create a shading with kColorCount colors and make sure all the values are there.
+ const NSUInteger kColorCount = 100;
+ NSColor *theColors[kColorCount];
+ CGFloat thePositions[kColorCount];
+ const CGFloat kColorIncrement = 1.0 / kColorCount;
+ for (NSUInteger i = 0; i < kColorCount; i++) {
+ CGFloat newValue = kColorIncrement * i;
+ thePositions[i] = newValue;
+ theColors[i] = [NSColor colorWithCalibratedRed:newValue
+ green:newValue
+ blue:newValue
+ alpha:newValue];
+ }
+ GTMLinearRGBShading *theShading =
+ [GTMLinearRGBShading shadingWithColors:theColors
+ fromSpaceNamed:NSCalibratedRGBColorSpace
+ atPositions:thePositions
+ count:kColorCount];
+ for (NSUInteger i = 0; i < kColorCount; i++) {
+ CGFloat newValue = kColorIncrement * i;
+ CGFloat *theColor = (CGFloat*)[theShading valueAtPosition:newValue];
+ STAssertEqualsWithAccuracy(theColor[0], newValue, 0.001, nil);
+ STAssertEqualsWithAccuracy(theColor[1], newValue, 0.001, nil);
+ STAssertEqualsWithAccuracy(theColor[2], newValue, 0.001, nil);
+ STAssertEqualsWithAccuracy(theColor[3], newValue, 0.001, nil);
+ }
+}
+
+- (void)testShadeFunction {
+ GTMLinearRGBShading *theShading =
+ [GTMLinearRGBShading shadingWithColors:nil
+ fromSpaceNamed:NSCalibratedRGBColorSpace
+ atPositions:nil
+ count:0];
+ CGFunctionRef theFunction = [theShading shadeFunction];
+ STAssertNotNULL(theFunction, nil);
+ STAssertEquals(CFGetTypeID(theFunction), CGFunctionGetTypeID(), nil);
+}
+
+- (void)testColorSpace {
+ GTMLinearRGBShading *theShading =
+ [GTMLinearRGBShading shadingWithColors:nil
+ fromSpaceNamed:NSCalibratedRGBColorSpace
+ atPositions:nil
+ count:0];
+ CGColorSpaceRef theColorSpace = [theShading colorSpace];
+ STAssertNotNULL(theColorSpace, nil);
+ STAssertEquals(CFGetTypeID(theColorSpace), CGColorSpaceGetTypeID(), nil);
+}
+@end
87 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMLoginItems.h
View
@@ -0,0 +1,87 @@
+//
+// GTMLoginItems.h
+//
+// Copyright 2007-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <Foundation/Foundation.h>
+
+/// Login items key constants, used as keys in |+loginItems|
+//
+// Item name
+extern NSString * const kGTMLoginItemsNameKey;
+// Item path
+extern NSString * const kGTMLoginItemsPathKey;
+// Hidden (NSNumber bool)
+extern NSString * const kGTMLoginItemsHiddenKey;
+
+/// GTMLoginItems
+//
+/// A helper class to manipulate the user's Login Items.
+@interface GTMLoginItems : NSObject
+
+/// Obtain a complete list of all login items.
+//
+// Returns:
+// Autoreleased array of dictionaries keyed with kGTMLoginItemsPathKey, etc.
+//
++ (NSArray *)loginItems:(NSError **)errorInfo;
+
+/// Check if the given path is in the current user's Login Items
+//
+// Args:
+// path: path to the application
+//
+// Returns:
+// YES if the path is in the Login Items
+//
++ (BOOL)pathInLoginItems:(NSString *)path;
+
+/// Check if the given name is in the current user's Login Items
+//
+// Args:
+// name: name to the application
+//
+// Returns:
+// YES if the name is in the Login Items
+//
++ (BOOL)itemWithNameInLoginItems:(NSString *)name;
+
+/// Add the given path to the current user's Login Items. Does nothing if the
+/// path is already there.
+//
+// Args:
+// path: path to add
+// hide: Set to YES to have the item launch hidden
+//
++ (void)addPathToLoginItems:(NSString *)path hide:(BOOL)hide;
+
+/// Remove the given path from the current user's Login Items. Does nothing if
+/// the path is not there.
+//
+// Args:
+// path: the path to remove
+//
++ (void)removePathFromLoginItems:(NSString *)path;
+
+/// Remove the given item name from the current user's Login Items. Does nothing
+/// if no item with that name is present.
+//
+// Args:
+// name: name of the item to remove
+//
++ (void)removeItemWithNameFromLoginItems:(NSString *)name;
+
+@end
184 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMLoginItems.m
View
@@ -0,0 +1,184 @@
+//
+// GTMLoginItems.m
+// Based on AELoginItems from DTS.
+//
+// Copyright 2007-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import "GTMLoginItems.h"
+#import "GTMDefines.h"
+
+#include <Carbon/Carbon.h>
+
+// Exposed constants
+NSString * const kGTMLoginItemsNameKey = @"Name";
+NSString * const kGTMLoginItemsPathKey = @"Path";
+NSString * const kGTMLoginItemsHiddenKey = @"Hide";
+
+@interface GTMLoginItems (PrivateMethods)
++ (NSInteger)indexOfLoginItemWithValue:(id)value
+ forKey:(NSString *)key
+ loginItems:(NSArray *)items;
++ (BOOL)compileAndRunScript:(NSString *)script
+ withError:(NSError **)errorInfo;
+@end
+
+@implementation GTMLoginItems (PrivateMethods)
+
++ (NSInteger)indexOfLoginItemWithValue:(id)value
+ forKey:(NSString *)key
+ loginItems:(NSArray *)items {
+ if (!value || !key || !items) return NSNotFound;
+ NSDictionary *item = nil;
+ NSEnumerator *itemsEnum = [items objectEnumerator];
+ NSInteger found = -1;
+ while ((item = [itemsEnum nextObject])) {
+ ++found;
+ id itemValue = [item objectForKey:key];
+ if (itemValue && [itemValue isEqual:value]) {
+ return found;
+ }
+ }
+ return NSNotFound;
+}
+
++ (BOOL)compileAndRunScript:(NSString *)script
+ withError:(NSError **)errorInfo {
+ if ([script length] == 0) {
+ if (errorInfo)
+ *errorInfo = [NSError errorWithDomain:@"GTMLoginItems" code:-90 userInfo:nil];
+ return NO;
+ }
+ NSAppleScript *query = [[[NSAppleScript alloc] initWithSource:script] autorelease];
+ NSDictionary *errDict = nil;
+ if ( ![query compileAndReturnError:&errDict]) {
+ if (errorInfo)
+ *errorInfo = [NSError errorWithDomain:@"GTMLoginItems" code:-91 userInfo:errDict];
+ return NO;
+ }
+ NSAppleEventDescriptor *scriptResult = [query executeAndReturnError:&errDict];
+ if (!scriptResult) {
+ if (*errorInfo)
+ *errorInfo = [NSError errorWithDomain:@"GTMLoginItems" code:-92 userInfo:errDict];
+ return NO;
+ }
+ // we don't process the result
+ return YES;
+}
+
+@end
+
+@implementation GTMLoginItems
+
++ (NSArray*)loginItems:(NSError **)errorInfo {
+ NSDictionary *errDict = nil;
+ // get the script compiled and saved off
+ static NSAppleScript *query = nil;
+ if (!query) {
+ NSString *querySource = @"tell application \"System Events\" to get properties of login items";
+ query = [[NSAppleScript alloc] initWithSource:querySource];
+ if ( ![query compileAndReturnError:&errDict]) {
+ if (errorInfo)
+ *errorInfo = [NSError errorWithDomain:@"GTMLoginItems" code:-1 userInfo:errDict];
+ [query release];
+ query = nil;
+ return nil;
+ }
+ }
+ // run the script
+ NSAppleEventDescriptor *scriptResult = [query executeAndReturnError:&errDict];
+ if (!scriptResult) {
+ if (*errorInfo)
+ *errorInfo = [NSError errorWithDomain:@"GTMLoginItems" code:-2 userInfo:errDict];
+ return nil;
+ }
+ // build our results
+ NSMutableArray *result = [NSMutableArray array];
+ NSInteger count = [scriptResult numberOfItems];
+ for (NSInteger i = 0; i < count; ++i) {
+ NSAppleEventDescriptor *aeItem = [scriptResult descriptorAtIndex:i+1];
+ NSAppleEventDescriptor *hidn = [aeItem descriptorForKeyword:kAEHidden];
+ NSAppleEventDescriptor *nam = [aeItem descriptorForKeyword:pName];
+ NSAppleEventDescriptor *ppth = [aeItem descriptorForKeyword:'ppth'];
+ NSMutableDictionary *item = [NSMutableDictionary dictionary];
+ if (hidn && [hidn booleanValue]) {
+ [item setObject:[NSNumber numberWithBool:YES] forKey:kGTMLoginItemsHiddenKey];
+ }
+ if (nam) {
+ NSString *name = [nam stringValue];
+ if (name) {
+ [item setObject:name forKey:kGTMLoginItemsNameKey];
+ }
+ }
+ if (ppth) {
+ NSString *path = [ppth stringValue];
+ if (path) {
+ [item setObject:path forKey:kGTMLoginItemsPathKey];
+ }
+ }
+ [result addObject:item];
+ }
+
+ return result;
+}
+
++ (BOOL)pathInLoginItems:(NSString *)path {
+ NSArray *loginItems = [self loginItems:nil];
+ NSInteger itemIndex = [self indexOfLoginItemWithValue:path
+ forKey:kGTMLoginItemsPathKey
+ loginItems:loginItems];
+ return (itemIndex != NSNotFound) ? YES : NO;
+}
+
++ (BOOL)itemWithNameInLoginItems:(NSString *)name {
+ NSArray *loginItems = [self loginItems:nil];
+ NSInteger itemIndex = [self indexOfLoginItemWithValue:name
+ forKey:kGTMLoginItemsNameKey
+ loginItems:loginItems];
+ return (itemIndex != NSNotFound) ? YES : NO;
+}
+
++ (void)addPathToLoginItems:(NSString*)path hide:(BOOL)hide {
+ if (!path) return;
+ // make sure it isn't already there
+ if ([self pathInLoginItems:path]) return;
+ // now append it
+ NSString *scriptSource =
+ [NSString stringWithFormat:
+ @"tell application \"System Events\" to make new login item with properties { path:\"%s\", hidden:%s } at end",
+ [path UTF8String],
+ (hide ? "yes" : "no")];
+ [self compileAndRunScript:scriptSource withError:nil];
+}
+
++ (void)removePathFromLoginItems:(NSString*)path {
+ if ([path length] == 0) return;
+ NSString *scriptSource =
+ [NSString stringWithFormat:
+ @"tell application \"System Events\" to delete (login items whose path is \"%s\")",
+ [path UTF8String]];
+ [self compileAndRunScript:scriptSource withError:nil];
+}
+
++ (void)removeItemWithNameFromLoginItems:(NSString *)name {
+ if ([name length] == 0) return;
+ NSString *scriptSource =
+ [NSString stringWithFormat:
+ @"tell application \"System Events\" to delete (login items whose name is \"%s\")",
+ [name UTF8String]];
+ [self compileAndRunScript:scriptSource withError:nil];
+}
+
+@end
112 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMLoginItemsTest.m
View
@@ -0,0 +1,112 @@
+//
+// GTMLoginItemsTest.m
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <SenTestingKit/SenTestingKit.h>
+#import "GTMSenTestCase.h"
+#import "GTMLoginItems.h"
+
+ // we don't really run this test because if someone had it in some automated
+ // tests, then if something did fail, it could leave things in the login items
+ // on the computer which could be a nasty surprise.
+#define TESTS_ENABLED 0
+
+
+@interface GTMLoginItemsTest : GTMTestCase
+@end
+
+#if TESTS_ENABLED
+
+static BOOL ItemsListHasPath(NSArray *items, NSString *path) {
+ NSDictionary *item = nil;
+ NSEnumerator *itemsEnum = [items objectEnumerator];
+ while ((item = [itemsEnum nextObject])) {
+ NSString *itemPath = [item objectForKey:kGTMLoginItemsPathKey];
+ if (itemPath && [itemPath isEqual:path]) {
+ return YES;
+ }
+ }
+ return NO;
+}
+
+#endif // TESTS_ENABLED
+
+@implementation GTMLoginItemsTest
+
+- (void)testGTMLoginItems {
+
+#if TESTS_ENABLED
+
+ NSError *error = nil;
+ NSString *textEditPath = @"/Applications/TextEdit.app";
+ NSString *textEditName = @"TextEdit";
+
+ // fetch the starting values
+ NSArray *initialItems = [GTMLoginItems loginItems:&error];
+ STAssertNotNil(initialItems, @"shouldn't be nil (%@)", error);
+ STAssertFalse(ItemsListHasPath(initialItems, textEditPath),
+ @"textedit shouldn't be in list to start for test (%@)", initialItems);
+
+ // add textedit
+ [GTMLoginItems addPathToLoginItems:textEditPath hide:NO];
+ NSArray *curItems = [GTMLoginItems loginItems:nil];
+ STAssertNotEqualObjects(initialItems, curItems, nil);
+
+ // check by path
+ STAssertTrue([GTMLoginItems pathInLoginItems:textEditPath], nil);
+
+ // check by name
+ STAssertTrue([GTMLoginItems itemWithNameInLoginItems:textEditName], nil);
+
+ // remove it by path
+ [GTMLoginItems removePathFromLoginItems:textEditPath];
+ curItems = [GTMLoginItems loginItems:nil];
+ STAssertEqualObjects(initialItems, curItems, nil);
+
+ // check by path
+ STAssertFalse([GTMLoginItems pathInLoginItems:textEditPath], nil);
+
+ // check by name
+ STAssertFalse([GTMLoginItems itemWithNameInLoginItems:textEditName], nil);
+
+ // add textedit
+ [GTMLoginItems addPathToLoginItems:textEditPath hide:NO];
+ curItems = [GTMLoginItems loginItems:nil];
+ STAssertNotEqualObjects(initialItems, curItems, nil);
+
+ // check by path
+ STAssertTrue([GTMLoginItems pathInLoginItems:textEditPath], nil);
+
+ // check by name
+ STAssertTrue([GTMLoginItems itemWithNameInLoginItems:textEditName], nil);
+
+ // remove it by name
+ [GTMLoginItems removeItemWithNameFromLoginItems:textEditName];
+ curItems = [GTMLoginItems loginItems:nil];
+ STAssertEqualObjects(initialItems, curItems, nil);
+
+ // check by path
+ STAssertFalse([GTMLoginItems pathInLoginItems:textEditPath], nil);
+
+ // check by name
+ STAssertFalse([GTMLoginItems itemWithNameInLoginItems:textEditName], nil);
+
+#endif // TESTS_ENABLED
+
+}
+
+@end
33 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+CGPath.h
View
@@ -0,0 +1,33 @@
+//
+// GTMNSBezierPath+CGPath.h
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <Cocoa/Cocoa.h>
+
+/// Category for extracting a CGPathRef from a NSBezierPath
+@interface NSBezierPath (GTMBezierPathCGPathAdditions)
+
+/// Extract a CGPathRef from a NSBezierPath.
+//
+// Args:
+//
+// Returns:
+// Converted CGPathRef. Must be released by client (CGPathRelease).
+// nil if failure.
+- (CGPathRef)gtm_createCGPath;
+
+@end
69 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+CGPath.m
View
@@ -0,0 +1,69 @@
+//
+// GTMNSBezierPath+CGPath.m
+//
+// Category for extracting a CGPathRef from a NSBezierPath
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+#import "GTMNSBezierPath+CGPath.h"
+#import "GTMDefines.h"
+
+@implementation NSBezierPath (GTMBezierPathCGPathAdditions)
+
+// Extract a CGPathRef from a NSBezierPath.
+//
+// Args:
+//
+// Returns:
+// Converted CGPathRef. Must be released by client (CGPathRelease).
+// nil if failure.
+- (CGPathRef)gtm_createCGPath {
+ CGMutablePathRef thePath = CGPathCreateMutable();
+ if (!thePath) return nil;
+
+ NSInteger elementCount = [self elementCount];
+
+ // The maximum number of points is 3 for a NSCurveToBezierPathElement.
+ // (controlPoint1, controlPoint2, and endPoint)
+ NSPoint controlPoints[3];
+
+ for (NSInteger i = 0; i < elementCount; i++) {
+ switch ([self elementAtIndex:i associatedPoints:controlPoints]) {
+ case NSMoveToBezierPathElement:
+ CGPathMoveToPoint(thePath, &CGAffineTransformIdentity,
+ controlPoints[0].x, controlPoints[0].y);
+ break;
+ case NSLineToBezierPathElement:
+ CGPathAddLineToPoint(thePath, &CGAffineTransformIdentity,
+ controlPoints[0].x, controlPoints[0].y);
+ break;
+ case NSCurveToBezierPathElement:
+ CGPathAddCurveToPoint(thePath, &CGAffineTransformIdentity,
+ controlPoints[0].x, controlPoints[0].y,
+ controlPoints[1].x, controlPoints[1].y,
+ controlPoints[2].x, controlPoints[2].y);
+ break;
+ case NSClosePathBezierPathElement:
+ CGPathCloseSubpath(thePath);
+ break;
+ default:
+ _GTMDevLog(@"Unknown element at [NSBezierPath (GTMBezierPathCGPathAdditions) cgPath]");
+ break;
+ };
+ }
+ return thePath;
+}
+
+@end
76 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+CGPathTest.m
View
@@ -0,0 +1,76 @@
+//
+// GTMNSBezierPath+CGPathTest.m
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <Cocoa/Cocoa.h>
+
+#import <SenTestingKit/SenTestingKit.h>
+#import "GTMNSBezierPath+CGPath.h"
+#import "GTMAppKit+UnitTesting.h"
+#import "GTMSenTestCase.h"
+
+@interface GTMNSBezierPath_CGPathTest : GTMTestCase<GTMUnitTestViewDrawer>
+@end
+
+@implementation GTMNSBezierPath_CGPathTest
+
+- (void)testCreateCGPath {
+ GTMAssertDrawingEqualToImageNamed(self,
+ NSMakeSize(100, 100),
+ @"GTMNSBezierPath+CGPathTest",
+ nil, nil);
+}
+
+
+// Draws all of our tests so that we can compare this to our stored image file.
+- (void)gtm_unitTestViewDrawRect:(NSRect)rect contextInfo:(void*)contextInfo{
+ NSBezierPath *thePath = [NSBezierPath bezierPath];
+ NSPoint theStart = NSMakePoint(20.0, 20.0);
+
+ // Test moveto/lineto
+ [thePath moveToPoint: theStart];
+ for (NSUInteger i = 0; i < 10; ++i) {
+ NSPoint theNewPoint = NSMakePoint(i * 5, i * 10);
+ [thePath lineToPoint: theNewPoint];
+ theNewPoint = NSMakePoint(i * 2, i * 6);
+ [thePath moveToPoint: theNewPoint];
+ }
+
+ // Test moveto/curveto
+ for (NSUInteger i = 0; i < 10; ++i) {
+ NSPoint startPoint = NSMakePoint(5.0, 50.0);
+ NSPoint endPoint = NSMakePoint(55.0, 50.0);
+ NSPoint controlPoint1 = NSMakePoint(17.5, 50.0 + 5.0 * i);
+ NSPoint controlPoint2 = NSMakePoint(42.5, 50.0 - 5.0 * i);
+ [thePath moveToPoint:startPoint];
+ [thePath curveToPoint:endPoint controlPoint1:controlPoint1 controlPoint2:controlPoint2];
+ }
+ // test close
+ [thePath closePath];
+
+ CGPathRef cgPath = [thePath gtm_createCGPath];
+ STAssertNotNULL(cgPath, @"Nil CGPath");
+
+ CGContextRef cgContext = [[NSGraphicsContext currentContext] graphicsPort];
+ STAssertNotNULL(cgContext, @"Nil cgContext");
+
+ CGContextAddPath(cgContext, cgPath);
+ CGContextStrokePath(cgContext);
+ CGPathRelease(cgPath);
+}
+
+@end
48 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+RoundRect.h
View
@@ -0,0 +1,48 @@
+//
+// GTMNSBezierPath+RoundRect.h
+//
+// Category for adding utility functions for creating
+// round rectangles.
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <Cocoa/Cocoa.h>
+#import "GTMDefines.h"
+
+/// Category for adding utility functions for creating round rectangles.
+@interface NSBezierPath (GMBezierPathRoundRectAdditions)
+
+/// Inscribe a round rectangle inside of rectangle |rect| with a corner radius of |radius|
+//
+// Args:
+// rect: outer rectangle to inscribe into
+// radius: radius of the corners. |radius| is clamped internally
+// to be no larger than the smaller of half |rect|'s width or height
+//
+// Returns:
+// Auto released NSBezierPath
++ (NSBezierPath *)gtm_bezierPathWithRoundRect:(NSRect)rect
+ cornerRadius:(CGFloat)radius;
+
+/// Adds a path which is a round rectangle inscribed inside of rectangle |rect| with a corner radius of |radius|
+//
+// Args:
+// rect: outer rectangle to inscribe into
+// radius: radius of the corners. |radius| is clamped internally
+// to be no larger than the smaller of half |rect|'s width or height
+- (void)gtm_appendBezierPathWithRoundRect:(NSRect)rect
+ cornerRadius:(CGFloat)radius;
+@end
68 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+RoundRect.m
View
@@ -0,0 +1,68 @@
+//
+// GTMNSBezierPath+RoundRect.h
+//
+// Category for adding utility functions for creating
+// round rectangles.
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import "GTMNSBezierPath+RoundRect.h"
+
+@implementation NSBezierPath (GTMBezierPathRoundRectAdditions)
+
+
++ (NSBezierPath *)gtm_bezierPathWithRoundRect:(NSRect)rect
+ cornerRadius:(CGFloat)radius {
+ NSBezierPath *bezier = [NSBezierPath bezierPath];
+ [bezier gtm_appendBezierPathWithRoundRect:rect cornerRadius:radius];
+ return bezier;
+}
+
+
+- (void)gtm_appendBezierPathWithRoundRect:(NSRect)rect
+ cornerRadius:(CGFloat)radius {
+ if (!NSIsEmptyRect(rect)) {
+ if (radius > 0.0) {
+ // Clamp radius to be no larger than half the rect's width or height.
+ radius = MIN(radius, 0.5 * MIN(rect.size.width, rect.size.height));
+
+ NSPoint topLeft = NSMakePoint(NSMinX(rect), NSMaxY(rect));
+ NSPoint topRight = NSMakePoint(NSMaxX(rect), NSMaxY(rect));
+ NSPoint bottomRight = NSMakePoint(NSMaxX(rect), NSMinY(rect));
+
+ [self moveToPoint:NSMakePoint(NSMidX(rect), NSMaxY(rect))];
+ [self appendBezierPathWithArcFromPoint:topLeft
+ toPoint:rect.origin
+ radius:radius];
+ [self appendBezierPathWithArcFromPoint:rect.origin
+ toPoint:bottomRight
+ radius:radius];
+ [self appendBezierPathWithArcFromPoint:bottomRight
+ toPoint:topRight
+ radius:radius];
+ [self appendBezierPathWithArcFromPoint:topRight
+ toPoint:topLeft
+ radius:radius];
+ [self closePath];
+ } else {
+ // When radius <= 0.0, use plain rectangle.
+ [self appendBezierPathWithRect:rect];
+ }
+ }
+}
+
+
+@end
98 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+RoundRectTest.m
View
@@ -0,0 +1,98 @@
+//
+// NSBezierPath+RoundRectTest.m
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <Cocoa/Cocoa.h>
+
+#import <SenTestingKit/SenTestingKit.h>
+#import "GTMNSBezierPath+RoundRect.h"
+#import "GTMAppKit+UnitTesting.h"
+
+@interface GTMNSBezierPath_RoundRectTest : GTMTestCase<GTMUnitTestViewDrawer>
+@end
+
+@implementation GTMNSBezierPath_RoundRectTest
+
+- (void)testRoundRects {
+ GTMAssertDrawingEqualToImageNamed(self, NSMakeSize(330, 430),
+ @"GTMNSBezierPath+RoundRectTest", nil, nil);
+}
+
+// Draws all of our tests so that we can compare this to our stored TIFF file.
+- (void)gtm_unitTestViewDrawRect:(NSRect)rect contextInfo:(void*)contextInfo{
+ NSRect theRects[] = {
+ NSMakeRect(0.0, 10.0, 0.0, 0.0), //Empty Rect test
+ NSMakeRect(50.0, 10.0, 30.0, 30.0), //Square Test
+ NSMakeRect(100.0, 10.0, 1.0, 2.0), //Small Test
+ NSMakeRect(120.0, 10.0, 15.0, 20.0), //Medium Test
+ NSMakeRect(140.0, 10.0, 150.0, 30.0) //Large Test
+ };
+ const NSUInteger theRectCount = sizeof(theRects) / sizeof(NSRect);
+
+ // Line Width Tests
+ CGFloat theLineWidths[] = { 0.5, 50.0, 2.0 };
+ const NSUInteger theLineWidthCount = sizeof(theLineWidths) / sizeof(CGFloat);
+ NSUInteger i,j;
+
+ for (i = 0; i < theLineWidthCount; ++i) {
+ for (j = 0; j < theRectCount; ++j) {
+ NSBezierPath *roundRect = [NSBezierPath gtm_bezierPathWithRoundRect:theRects[j]
+ cornerRadius:20.0];
+ [roundRect setLineWidth: theLineWidths[i]];
+ [roundRect stroke];
+ CGFloat newWidth = 35.0;
+ if (i < theLineWidthCount - 1) {
+ newWidth += theLineWidths[i + 1] + theLineWidths[i];
+ }
+ theRects[j].origin.y += newWidth;
+ }
+ }
+
+ // Fill test
+ NSColor *theColors[] = {
+ [NSColor colorWithCalibratedRed:1.0 green:0.0 blue:0.0 alpha:1.0],
+ [NSColor colorWithCalibratedRed:0.2 green:0.4 blue:0.6 alpha:0.4]
+ };
+ const NSUInteger theColorCount = sizeof(theColors)/sizeof(NSColor);
+
+ for (i = 0; i < theColorCount; ++i) {
+ for (j = 0; j < theRectCount; ++j) {
+ NSBezierPath *roundRect = [NSBezierPath gtm_bezierPathWithRoundRect:theRects[j]
+ cornerRadius:10.0];
+ [theColors[i] setFill];
+ [roundRect fill];
+ theRects[j].origin.y += 35.0;
+ }
+ }
+
+ // Flatness test
+ CGFloat theFlatness[] = {0.0, 0.1, 1.0, 10.0};
+ const NSUInteger theFlatnessCount = sizeof(theFlatness)/sizeof(CGFloat);
+
+ for (i = 0; i < theFlatnessCount; i++) {
+ for (j = 0; j < theRectCount; ++j) {
+ NSBezierPath *roundRect = [NSBezierPath gtm_bezierPathWithRoundRect:theRects[j]
+ cornerRadius:6.0];
+ [roundRect setFlatness:theFlatness[i]];
+ [roundRect stroke];
+ theRects[j].origin.y += 35.0;
+ }
+ }
+}
+
+
+@end
121 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+Shading.h
View
@@ -0,0 +1,121 @@
+//
+// GTMNSBezierPath+Shading.h
+//
+// Category for radial and axial stroke and fill functions for NSBezierPaths
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <Cocoa/Cocoa.h>
+#import "GTMDefines.h"
+
+@protocol GTMShading;
+
+//
+/// Category for radial and axial stroke and fill functions for NSBezierPaths
+//
+@interface NSBezierPath (GTMBezierPathShadingAdditions)
+
+/// Stroke the path axially with a color blend defined by |shading|.
+//
+/// The fill will extend from |fromPoint| to |toPoint| and will extend
+/// indefinitely perpendicular to the axis of the line defined by the
+/// two points. You can extend beyond the |fromPoint|/|toPoint by setting
+/// |extendingStart|/|extendingEnd| respectively.
+//
+// Args:
+// fromPoint: point to start the shading at
+// toPoint: point to end the shading at
+// extendingStart: should we extend the shading before |fromPoint| using
+// the first color in our shading?
+// extendingEnd: should we extend the shading after |toPoint| using the
+// last color in our shading?
+// shading: the shading to use to take our colors from.
+//
+- (void)gtm_strokeAxiallyFrom:(NSPoint)fromPoint to:(NSPoint)toPoint
+ extendingStart:(BOOL)extendingStart extendingEnd:(BOOL)extendingEnd
+ shading:(id<GTMShading>)shading;
+
+/// Stroke the path radially with a color blend defined by |shading|.
+//
+/// The fill will extend from the circle with center |fromPoint|
+/// and radius |fromRadius| to the circle with center |toPoint|
+/// with radius |toRadius|.
+/// You can extend beyond the |fromPoint|/|toPoint| by setting
+/// |extendingStart|/|extendingEnd| respectively.
+//
+// Args:
+// fromPoint: center of the circle to start the shading at
+// fromRadius: radius of the circle to start the shading at
+// toPoint: center of the circle to to end the shading at
+// toRadius: raidus of the circle to end the shading at
+// extendingStart: should we extend the shading before |fromPoint| using
+// the first color in our shading?
+// extendingEnd: should we extend the shading after |toPoint| using the
+// last color in our shading?
+// shading: the shading to use to take our colors from.
+//
+- (void)gtm_strokeRadiallyFrom:(NSPoint)fromPoint fromRadius:(CGFloat)fromRadius
+ to:(NSPoint)toPoint toRadius:(CGFloat)toRadius
+ extendingStart:(BOOL)extendingStart extendingEnd:(BOOL)extendingEnd
+ shading:(id<GTMShading>)shading;
+
+/// Fill the path radially with a color blend defined by |shading|.
+//
+/// The fill will extend from the circle with center |fromPoint|
+/// and radius |fromRadius| to the circle with center |toPoint|
+/// with radius |toRadius|.
+/// You can extend beyond the |fromPoint|/|toPoint by setting
+/// |extendingStart|/|extendingEnd| respectively.
+//
+// Args:
+// fromPoint: center of the circle to start the shading at
+// fromRadius: radius of the circle to start the shading at
+// toPoint: center of the circle to to end the shading at
+// toRadius: radius of the circle to end the shading at
+// extendingStart: should we extend the shading before |fromPoint| using
+// the first color in our shading?
+// extendingEnd: should we extend the shading after |toPoint| using the
+// last color in our shading?
+// shading: the shading to use to take our colors from.
+//
+- (void)gtm_fillAxiallyFrom:(NSPoint)fromPoint to:(NSPoint)toPoint
+ extendingStart:(BOOL)extendingStart extendingEnd:(BOOL)extendingEnd
+ shading:(id<GTMShading>)shading;
+
+/// Fill the path radially with a color blend defined by |shading|.
+//
+/// The fill will extend from the circle with center |fromPoint|
+/// and radius |fromRadius| to the circle with center |toPoint|
+/// with radius |toRadius|.
+/// You can extend beyond the |fromPoint|/|toPoint by setting
+/// |extendingStart|/|extendingEnd| respectively.
+//
+// Args:
+// fromPoint: center of the circle to start the shading at
+// fromRadius: radius of the circle to start the shading at
+// toPoint: center of the circle to to end the shading at
+// toRadius: radius of the circle to end the shading at
+// extendingStart: should we extend the shading before |fromPoint| using
+// the first color in our shading?
+// extendingEnd: should we extend the shading after |toPoint| using the
+// last color in our shading?
+// shading: the shading to use to take our colors from.
+//
+- (void)gtm_fillRadiallyFrom:(NSPoint)fromPoint fromRadius:(CGFloat)fromRadius
+ to:(NSPoint)toPoint toRadius:(CGFloat)toRadius
+ extendingStart:(BOOL)extendingStart extendingEnd:(BOOL)extendingEnd
+ shading:(id<GTMShading>)shading;
+@end
220 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+Shading.m
View
@@ -0,0 +1,220 @@
+//
+// GTMNSBezierPath+Shading.m
+//
+// Category for radial and axial stroke and fill functions for NSBezierPaths
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import "GTMNSBezierPath+Shading.h"
+#import "GTMNSBezierPath+CGPath.h"
+#import "GTMShading.h"
+#import "GTMGeometryUtils.h"
+#import "GTMMethodCheck.h"
+
+@interface NSBezierPath (GTMBezierPathShadingAdditionsPrivate)
+// Fills a CGPathRef either axially or radially with the given shading.
+//
+// Args:
+// path: path to fill
+// axially: if YES fill axially, otherwise fill radially
+// asStroke: if YES, clip to the stroke of the path, otherwise
+// clip to the fill
+// from: where to shade from
+// fromRadius: in a radial fill, the radius of the from circle
+// to: where to shade to
+// toRadius: in a radial fill, the radius of the to circle
+// extendingStart: if true, extend the fill with the first color of the shade
+// beyond |from| away from |to|
+// extendingEnd: if true, extend the fill with the last color of the shade
+// beyond |to| away from |from|
+// shading: the shading to use for the fill
+//
+- (void)gtm_fillCGPath:(CGPathRef)path
+ axially:(BOOL)axially
+ asStroke:(BOOL)asStroke
+ from:(NSPoint)fromPoint fromRadius:(CGFloat)fromRadius
+ to:(NSPoint)toPoint toRadius:(CGFloat)toRadius
+ extendingStart:(BOOL)extendingStart extendingEnd:(BOOL)extendingEnd
+ shading:(id<GTMShading>)shading;
+
+// Returns the point which is the projection of a line from point |pointA|
+// to |pointB| by length
+//
+// Args:
+// pointA: first point
+// pointB: second point
+// length: distance to project beyond |pointB| which is in line with
+// |pointA| and |pointB|
+//
+// Returns:
+// the projected point
+- (NSPoint)gtm_projectLineFrom:(NSPoint)pointA
+ to:(NSPoint)pointB
+ by:(CGFloat)length;
+@end
+
+
+@implementation NSBezierPath (GTMBezierPathAdditionsPrivate)
+
+- (void)gtm_fillCGPath:(CGPathRef)path
+ axially:(BOOL)axially asStroke:(BOOL)asStroke
+ from:(NSPoint)fromPoint fromRadius:(CGFloat)fromRadius
+ to:(NSPoint)toPoint toRadius:(CGFloat)toRadius
+ extendingStart:(BOOL)extendingStart extendingEnd:(BOOL)extendingEnd
+ shading:(id<GTMShading>)shading {
+ CGFunctionRef shadingFunction = [shading shadeFunction];
+ if (nil != shadingFunction) {
+ CGContextRef currentContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
+ if (nil != currentContext) {
+ CGContextSaveGState(currentContext);
+ CGFloat lineWidth = [self lineWidth];
+ CGContextSetLineWidth(currentContext, lineWidth);
+ if (asStroke) {
+ // if we are using the stroke, we offset the from and to points
+ // by half the stroke width away from the center of the stroke.
+ // Otherwise we tend to end up with fills that only cover half of the
+ // because users set the start and end points based on the center
+ // of the stroke.
+ CGFloat halfWidth = lineWidth * 0.5;
+ fromPoint = [self gtm_projectLineFrom:toPoint to:fromPoint by:halfWidth];
+ toPoint = [self gtm_projectLineFrom:fromPoint to:toPoint by:-halfWidth];
+ }
+ CGColorSpaceRef colorspace = [shading colorSpace];
+ if (nil != colorspace) {
+ CGPoint toCGPoint = GTMNSPointToCGPoint(toPoint);
+ CGPoint fromCGPoint = GTMNSPointToCGPoint(fromPoint);
+ CGShadingRef myCGShading;
+ if(axially) {
+ myCGShading = CGShadingCreateAxial(colorspace, fromCGPoint,
+ toCGPoint, shadingFunction,
+ extendingStart == YES,
+ extendingEnd == YES);
+ }
+ else {
+ myCGShading = CGShadingCreateRadial(colorspace, fromCGPoint, fromRadius,
+ toCGPoint, toRadius, shadingFunction,
+ extendingStart == YES,
+ extendingEnd == YES);
+ }
+
+ if (nil != myCGShading) {
+ CGContextAddPath(currentContext,path);
+ if(asStroke) {
+ CGContextReplacePathWithStrokedPath(currentContext);
+ }
+ CGContextClip(currentContext);
+ CGContextDrawShading(currentContext, myCGShading);
+ CGShadingRelease(myCGShading);
+ }
+ }
+ CGContextRestoreGState(currentContext);
+ }
+ }
+}
+
+
+- (NSPoint)gtm_projectLineFrom:(NSPoint)pointA
+ to:(NSPoint)pointB
+ by:(CGFloat)length {
+ NSPoint newPoint = pointB;
+ CGFloat x = (pointB.x - pointA.x);
+ CGFloat y = (pointB.y - pointA.y);
+ if (fpclassify(x) == FP_ZERO) {
+ newPoint.y += length;
+ } else if (fpclassify(y) == FP_ZERO) {
+ newPoint.x += length;
+ } else {
+#if CGFLOAT_IS_DOUBLE
+ CGFloat angle = atan(y / x);
+ newPoint.x += sin(angle) * length;
+ newPoint.y += cos(angle) * length;
+#else
+ CGFloat angle = atanf(y / x);
+ newPoint.x += sinf(angle) * length;
+ newPoint.y += cosf(angle) * length;
+#endif
+ }
+ return newPoint;
+}
+
+@end
+
+
+@implementation NSBezierPath (GTMBezierPathShadingAdditions)
+GTM_METHOD_CHECK(NSBezierPath, gtm_createCGPath); // COV_NF_LINE
+
+- (void)gtm_strokeAxiallyFrom:(NSPoint)fromPoint to:(NSPoint)toPoint
+ extendingStart:(BOOL)extendingStart extendingEnd:(BOOL)extendingEnd
+ shading:(id<GTMShading>)shading {
+ CGPathRef thePath = [self gtm_createCGPath];
+ if (nil != thePath) {
+ [self gtm_fillCGPath:thePath axially:YES asStroke:YES
+ from:fromPoint fromRadius:(CGFloat)0.0
+ to:toPoint toRadius:(CGFloat)0.0
+ extendingStart:extendingStart extendingEnd:extendingEnd
+ shading:shading];
+ CGPathRelease(thePath);
+ }
+}
+
+
+- (void)gtm_strokeRadiallyFrom:(NSPoint)fromPoint fromRadius:(CGFloat)fromRadius
+ to:(NSPoint)toPoint toRadius:(CGFloat)toRadius
+ extendingStart:(BOOL)extendingStart extendingEnd:(BOOL)extendingEnd
+ shading:(id<GTMShading>)shading {
+ CGPathRef thePath = [self gtm_createCGPath];
+ if (nil != thePath) {
+ [self gtm_fillCGPath:thePath axially:NO asStroke:YES
+ from:fromPoint fromRadius:fromRadius
+ to:toPoint toRadius:toRadius
+ extendingStart:extendingStart extendingEnd:extendingEnd
+ shading:shading];
+ CGPathRelease(thePath);
+ }
+}
+
+
+- (void)gtm_fillAxiallyFrom:(NSPoint)fromPoint to:(NSPoint)toPoint
+ extendingStart:(BOOL)extendingStart extendingEnd:(BOOL)extendingEnd
+ shading:(id<GTMShading>)shading {
+ CGPathRef thePath = [self gtm_createCGPath];
+ if (nil != thePath) {
+ [self gtm_fillCGPath:thePath axially:YES asStroke:NO
+ from:fromPoint fromRadius:(CGFloat)0.0
+ to:toPoint toRadius:(CGFloat)0.0
+ extendingStart:extendingStart extendingEnd:extendingEnd
+ shading:shading];
+ CGPathRelease(thePath);
+ }
+}
+
+
+- (void)gtm_fillRadiallyFrom:(NSPoint)fromPoint fromRadius:(CGFloat)fromRadius
+ to:(NSPoint)toPoint toRadius:(CGFloat)toRadius
+ extendingStart:(BOOL)extendingStart extendingEnd:(BOOL)extendingEnd
+ shading:(id<GTMShading>)shading {
+ CGPathRef thePath = [self gtm_createCGPath];
+ if (nil != thePath) {
+ [self gtm_fillCGPath:thePath axially:NO asStroke:NO
+ from:fromPoint fromRadius:fromRadius
+ to:toPoint toRadius:toRadius
+ extendingStart:extendingStart extendingEnd:extendingEnd
+ shading:shading];
+ CGPathRelease(thePath);
+ }
+}
+
+@end
95 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSBezierPath+ShadingTest.m
View
@@ -0,0 +1,95 @@
+//
+// GTMNSBezierPath+ShadingTest.m
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <Cocoa/Cocoa.h>
+
+#import <SenTestingKit/SenTestingKit.h>
+
+#import "GTMLinearRGBShading.h"
+#import "GTMAppKit+UnitTesting.h"
+#import "GTMNSBezierPath+Shading.h"
+
+@interface GTMNSBezierPath_ShadingTest : GTMTestCase<GTMUnitTestViewDrawer>
+@end
+
+@implementation GTMNSBezierPath_ShadingTest
+
+- (void)testShadings {
+ GTMAssertDrawingEqualToImageNamed(self,
+ NSMakeSize(200, 200),
+ @"GTMNSBezierPath+ShadingTest", nil, nil);
+}
+
+- (void)gtm_unitTestViewDrawRect:(NSRect)rect contextInfo:(void*)contextInfo {
+
+ NSColor *theColorArray[] = { [NSColor blueColor],
+ [NSColor redColor], [NSColor yellowColor],
+ [NSColor blueColor], [NSColor greenColor],
+ [NSColor redColor] };
+ CGFloat theFloatArray[] = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 };
+
+ GTMLinearRGBShading *shading =
+ [GTMLinearRGBShading shadingWithColors:theColorArray
+ fromSpaceNamed:NSCalibratedRGBColorSpace
+ atPositions:theFloatArray
+ count:sizeof(theFloatArray)/sizeof(CGFloat)];
+ NSBezierPath *shadedPath;
+
+ // axialStrokeRect test
+ NSRect axialStrokeRect = NSMakeRect(10.0f, 10.0f, 90.0f, 90.0f);
+ shadedPath = [NSBezierPath bezierPathWithRect:axialStrokeRect];
+ [shadedPath setLineWidth: 10.0f];
+ NSPoint startPoint = NSMakePoint(axialStrokeRect.origin.x + 20.0f,
+ axialStrokeRect.origin.y + 20.0f);
+ NSPoint endPoint = NSMakePoint(axialStrokeRect.origin.x + axialStrokeRect.size.width - 20.0f,
+ axialStrokeRect.origin.y + axialStrokeRect.size.height - 20.0f);
+ [shadedPath gtm_strokeAxiallyFrom:startPoint to:endPoint extendingStart:YES extendingEnd:YES shading:shading];
+
+ // axial fill
+ NSRect axialFillRect = NSMakeRect(10.0f, 110.0f, 90.0f, 90.0f);
+ shadedPath = [NSBezierPath bezierPathWithRect:axialFillRect];
+ startPoint = NSMakePoint(axialFillRect.origin.x + 20.0f,
+ axialFillRect.origin.y + 20.0f);
+ endPoint = NSMakePoint(axialFillRect.origin.x + axialFillRect.size.width - 20.0f,
+ axialFillRect.origin.y + axialFillRect.size.height - 20.0f);
+ [shadedPath gtm_fillAxiallyFrom:startPoint to:endPoint extendingStart:YES extendingEnd:YES shading:shading];
+
+ // radial stroke
+ NSRect radialStrokeRect = NSMakeRect(110.0f, 110.0f, 90.0f, 90.0f);
+ shadedPath = [NSBezierPath bezierPathWithRect:radialStrokeRect];
+ startPoint = NSMakePoint(radialStrokeRect.origin.x + 20.0f,
+ radialStrokeRect.origin.y + 20.0f);
+ endPoint = NSMakePoint(radialStrokeRect.origin.x + radialStrokeRect.size.width - 20.0f,
+ radialStrokeRect.origin.y + radialStrokeRect.size.height - 20.0f);
+ [shadedPath gtm_strokeRadiallyFrom:startPoint fromRadius:60.0f
+ to:endPoint toRadius:20.0f
+ extendingStart:YES extendingEnd:YES shading:shading];
+
+ // radial fill
+ NSRect radialFillRect = NSMakeRect(110.0f, 10.0f, 90.0f, 90.0f);
+ shadedPath = [NSBezierPath bezierPathWithRect:radialFillRect];
+ startPoint = NSMakePoint(radialFillRect.origin.x + 20.0f,
+ radialFillRect.origin.y + 20.0f);
+ endPoint = NSMakePoint(radialFillRect.origin.x + radialFillRect.size.width - 20.0f,
+ radialFillRect.origin.y + radialFillRect.size.height - 20.0f);
+ [shadedPath gtm_fillRadiallyFrom:startPoint fromRadius:10.0f
+ to:endPoint toRadius:20.0f
+ extendingStart:YES extendingEnd:YES shading:shading];
+}
+
+@end
33 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSWorkspace+ScreenSaver.h
View
@@ -0,0 +1,33 @@
+//
+// GTMNSWorkspace+ScreenSaver.h
+//
+// Category for seeing if the screen saver is running.
+// Requires linkage with the ScreenSaver.framework. Warning, uses some
+// undocumented methods in the ScreenSaver.framework.
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <Cocoa/Cocoa.h>
+
+@interface NSWorkspace (GTMScreenSaverAddition)
+
+// Check if the screen saver is running.
+// Returns YES if it is running.
+// Requires linking to the ScreenSaver.framework.
++ (BOOL)gtm_isScreenSaverActive;
+
+@end
+
132 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSWorkspace+ScreenSaver.m
View
@@ -0,0 +1,132 @@
+//
+// GTMNSWorkspace+ScreenSaver.m
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <Carbon/Carbon.h>
+#import <ScreenSaver/ScreenSaver.h>
+#import "GTMNSWorkspace+ScreenSaver.h"
+#import "GTMDefines.h"
+#import "GTMGarbageCollection.h"
+
+// Interesting class descriptions extracted from ScreenSaver.framework using
+// class-dump. Note that these are "not documented".
+
+@protocol ScreenSaverControl
+
+- (BOOL)screenSaverIsRunning;
+- (BOOL)screenSaverCanRun;
+- (void)setScreenSaverCanRun:(BOOL)fp8;
+- (void)screenSaverStartNow;
+- (void)screenSaverStopNow;
+- (void)restartForUser:(id)fp8;
+- (double)screenSaverTimeRemaining;
+- (void)screenSaverDidFade;
+- (BOOL)screenSaverIsRunningInBackground;
+- (void)screenSaverDidFadeInBackground:(BOOL)fp8
+ psnHi:(unsigned int)fp12
+ psnLow:(unsigned int)fp16;
+
+@end
+
+@interface ScreenSaverController : NSObject <ScreenSaverControl> {
+ NSConnection *_connection;
+ id _daemonProxy;
+ void *_reserved;
+}
+
++ (id)controller;
++ (id)monitor;
++ (id)daemonConnectionName;
++ (id)enginePath;
+- (void)_connectionClosed:(id)fp8;
+- (id)init;
+- (void)dealloc;
+- (BOOL)screenSaverIsRunning;
+- (BOOL)screenSaverCanRun;
+- (void)setScreenSaverCanRun:(BOOL)fp8;
+- (void)screenSaverStartNow;
+- (void)screenSaverStopNow;
+- (void)restartForUser:(id)fp8;
+- (double)screenSaverTimeRemaining;
+- (void)screenSaverDidFade;
+- (BOOL)screenSaverIsRunningInBackground;
+- (void)screenSaverDidFadeInBackground:(BOOL)fp8
+ psnHi:(unsigned int)fp12
+ psnLow:(unsigned int)fp16;
+
+@end
+
+// end of extraction
+
+@implementation NSWorkspace (GTMScreenSaverAddition)
+// Check if the screen saver is running.
++ (BOOL)gtm_isScreenSaverActive {
+ BOOL answer = NO;
+ ScreenSaverController *controller = nil;
+ // We're calling into an "undocumented" framework here, so we are going to
+ // step rather carefully (and in 10.5.2 it's only 32bit).
+
+#if !__LP64__
+ Class screenSaverControllerClass = NSClassFromString(@"ScreenSaverController");
+ _GTMDevAssert(screenSaverControllerClass,
+ @"Are you linked with ScreenSaver.framework?"
+ " Can't find ScreenSaverController class.");
+ if ([screenSaverControllerClass respondsToSelector:@selector(controller)]) {
+ controller = [ScreenSaverController controller];
+ if (controller) {
+ if ([controller respondsToSelector:@selector(screenSaverIsRunning)]) {
+ answer = [controller screenSaverIsRunning];
+ } else {
+ // COV_NF_START
+ _GTMDevLog(@"ScreenSaverController no longer supports -screenSaverIsRunning?");
+ controller = nil;
+ // COV_NF_END
+ }
+ }
+ }
+#endif // !__LP64__
+
+ if (!controller) {
+ // COV_NF_START
+ // If we can't get the controller, chances are we are being run from the
+ // command line and don't have access to the window server. As such we are
+ // going to fallback to the older method of figuring out if a screen saver
+ // is running.
+ ProcessSerialNumber psn;
+ // Check if the saver is already running
+ require_noerr(GetFrontProcess(&psn), CantGetFrontProcess);
+
+ CFDictionaryRef cfProcessInfo
+ = ProcessInformationCopyDictionary(&psn,
+ kProcessDictionaryIncludeAllInformationMask);
+
+ require(cfProcessInfo, CantGetFrontProcess);
+ NSDictionary *processInfo = [GTMNSMakeCollectable(cfProcessInfo) autorelease];
+ NSString *bundlePath = [processInfo objectForKey:@"BundlePath"];
+
+ // ScreenSaverEngine is the frontmost app if the screen saver is actually
+ // running Security Agent is the frontmost app if the "enter password"
+ // dialog is showing
+ answer = [bundlePath hasSuffix:@"ScreenSaverEngine.app"] ||
+ [bundlePath hasSuffix:@"SecurityAgent.app"];
+ // COV_NF_END
+ }
+CantGetFrontProcess:
+ return answer;
+}
+
+@end
33 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMNSWorkspace+ScreenSaverTest.m
View
@@ -0,0 +1,33 @@
+//
+// GTMNSWorkspace+ScreenSaverTest.m
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+#import "GTMSenTestCase.h"
+#import "GTMNSWorkspace+ScreenSaver.h"
+
+@interface GTMNSWorkspace_ScreenSaverTest : GTMTestCase
+@end
+
+
+@implementation GTMNSWorkspace_ScreenSaverTest
+
+- (void)testIsScreenSaverActive {
+ // Not much of a test, just executes the code. Couldn't think of a
+ // good way of verifying this one.
+ [NSWorkspace gtm_isScreenSaverActive];
+}
+
+@end
41 Source/External/google-toolbox-for-mac-1-5-1/AppKit/GTMShading.h
View
@@ -0,0 +1,41 @@
+//
+// GTMShading.h
+//
+// A protocol for an object that can be used as a shader.
+//
+// Copyright 2006-2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+/// \cond Protocols
+
+@protocol GTMShading
+// Returns the shadefunction for using in a shader.
+// This shadefunction shoud never be released. It is owned by the implementor
+// of the GTMShading protocol.
+//
+// Returns:
+// a shading function.
+- (CGFunctionRef)shadeFunction;
+
+// Returns the colorSpace for using in a shader.
+// This colorSpace shoud never be released. It is owned by the implementor
+// of the GTMShading protocol.
+//
+// Returns:
+// a color space.
+- (CGColorSpaceRef)colorSpace;
+@end
+
+/// \endcond
BIN  Source/External/google-toolbox-for-mac-1-5-1/AppKit/TestData/GTMNSBezierPath+CGPathTest.ppc64.tiff
View
Binary file not shown
BIN  Source/External/google-toolbox-for-mac-1-5-1/AppKit/TestData/GTMNSBezierPath+CGPathTest.tiff
View
Binary file not shown
BIN  Source/External/google-toolbox-for-mac-1-5-1/AppKit/TestData/GTMNSBezierPath+CGPathTest.x86_64.tiff
View
Binary file not shown
BIN  Source/External/google-toolbox-for-mac-1-5-1/AppKit/TestData/GTMNSBezierPath+RoundRectTest.ppc64.tiff
View
Binary file not shown
BIN  Source/External/google-toolbox-for-mac-1-5-1/AppKit/TestData/GTMNSBezierPath+RoundRectTest.tiff
View
Binary file not shown
BIN  Source/External/google-toolbox-for-mac-1-5-1/AppKit/TestData/GTMNSBezierPath+RoundRectTest.x86_64.tiff
View
Binary file not shown
BIN  Source/External/google-toolbox-for-mac-1-5-1/AppKit/TestData/GTMNSBezierPath+ShadingTest.10.5.tiff
View
Binary file not shown
54 Source/External/google-toolbox-for-mac-1-5-1/BuildScripts/BuildAllSDKs.sh
View
@@ -0,0 +1,54 @@
+#!/bin/sh
+# BuildAllSDKs.sh
+#
+# This script builds both the Tiger and Leopard versions of the requested
+# target in the current basic config (debug, release, debug-gcov). This script
+# should be run from the same directory as the GTM Xcode project file.
+#
+# Copyright 2006-2008 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy
+# of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+PROJECT_TARGET="$1"
+
+XCODEBUILD="${DEVELOPER_BIN_DIR}/xcodebuild"
+REQUESTED_BUILD_STYLE=$(echo "${BUILD_STYLE}" | sed "s/.*OrLater-\(.*\)/\1/")
+# See if we were told to clean instead of build.
+PROJECT_ACTION="build"
+if [ "${ACTION}" == "clean" ]; then
+ PROJECT_ACTION="clean"
+fi
+
+# helper for doing a build
+function doIt {
+ local myProject=$1
+ local myTarget=$2
+ local myConfig=$3
+ echo "note: Starting ${PROJECT_ACTION} of ${myTarget} from ${myProject} in ${myConfig}"
+ ${XCODEBUILD} -project "${myProject}" \
+ -target "${myTarget}" \
+ -configuration "${myConfig}" \
+ "${PROJECT_ACTION}"
+ buildResult=$?
+ if [ $buildResult -ne 0 ]; then
+ echo "Error: ** ${PROJECT_ACTION} Failed **"
+ exit $buildResult
+ fi
+ echo "note: Done ${PROJECT_ACTION}"
+}
+
+# now build tiger and then leopard
+doIt GTM.xcodeproj "${PROJECT_TARGET}" "TigerOrLater-${REQUESTED_BUILD_STYLE}"
+doIt GTM.xcodeproj "${PROJECT_TARGET}" "LeopardOrLater-${REQUESTED_BUILD_STYLE}"
+
+# TODO(iphone if right tool chain?)
18 Source/External/google-toolbox-for-mac-1-5-1/BuildingAndUsing.txt
View
@@ -0,0 +1,18 @@
+The GTM project provides a Framework target and Unit Testing targets.
+
+Unit Testing Targets -
+
+These targets are there to make sure all of GTM is working, and reflect the
+hierarchy of the source tree.
+
+Building the "All UnitTests" target will build all of the unittests for the
+current configuration included in the GTM package. We require that "All
+UnitTests" builds cleanly before we will accept any code submissions.
+
+Framework Target -
+
+These targets are there to make it easy for anyone to quickly add GTM sources
+to their own project to start using it or playing around with it. However,
+the intent is for a developer to manually add the sources to their project in
+the end to reduce the total size of their product (since they only have to
+include the parts of GTM they need).
202 Source/External/google-toolbox-for-mac-1-5-1/COPYING
View
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.