mirror of
https://github.com/arsenetar/dupeguru-cocoa.git
synced 2024-12-06 12:49:02 +00:00
Convert cocoalib submodule to be in place.
This commit is contained in:
parent
ce0bb606b2
commit
99b98db93a
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -4,6 +4,3 @@
|
||||
[submodule "hscommon"]
|
||||
path = hscommon
|
||||
url = https://github.com/hsoft/hscommon.git
|
||||
[submodule "cocoalib"]
|
||||
path = cocoalib
|
||||
url = https://github.com/hsoft/cocoalib.git
|
||||
|
1
cocoalib
1
cocoalib
@ -1 +0,0 @@
|
||||
Subproject commit 8ce3727c704f824f167a36c72c58b4b16d1ab6a3
|
6
cocoalib/.gitignore
vendored
Normal file
6
cocoalib/.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
.DS_Store
|
||||
__pycache__
|
||||
autogen
|
||||
*.so
|
||||
/*.lproj/*.strings
|
||||
!/Base.lproj/Localizable.strings
|
8
cocoalib/.tx/config
Normal file
8
cocoalib/.tx/config
Normal file
@ -0,0 +1,8 @@
|
||||
[main]
|
||||
host = https://www.transifex.com
|
||||
|
||||
[hscommon.cocoalib]
|
||||
file_filter = locale/<lang>/LC_MESSAGES/cocoalib.po
|
||||
source_file = locale/cocoalib.pot
|
||||
source_lang = en
|
||||
type = PO
|
213
cocoalib/Base.lproj/ErrorReportWindow.xib
Normal file
213
cocoalib/Base.lproj/ErrorReportWindow.xib
Normal file
@ -0,0 +1,213 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="HSErrorReportWindow">
|
||||
<connections>
|
||||
<outlet property="contentTextView" destination="20" id="21"/>
|
||||
<outlet property="window" destination="1" id="11"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application"/>
|
||||
<window title="Error report" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="1">
|
||||
<windowStyleMask key="styleMask" titled="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="477" y="263" width="524" height="469"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
|
||||
<view key="contentView" misplaced="YES" id="2">
|
||||
<rect key="frame" x="0.0" y="0.0" width="524" height="469"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" misplaced="YES" allowsCharacterPickerTouchBarItem="NO" id="3">
|
||||
<rect key="frame" x="17" y="415" width="490" height="34"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Something went wrong. Would you like to send the error report to Hardcoded Software?" id="4">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" misplaced="YES" allowsCharacterPickerTouchBarItem="NO" id="22">
|
||||
<rect key="frame" x="16" y="59" width="490" height="119"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" sendsActionOnEndEditing="YES" id="23">
|
||||
<font key="font" metaFont="system"/>
|
||||
<mutableString key="title">Error reports should be reported as Github issues. You can copy the error traceback above and paste it in a new issue (bonus point if you run a search to make sure the issue doesn't already exist). What usually really helps is if you add a description of how you got the error. Thanks!
Although the application should continue to run after this error, it may be in an unstable state, so it is recommended that you restart the application.</mutableString>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button verticalHuggingPriority="750" imageHugsTitle="YES" id="9">
|
||||
<rect key="frame" x="293" y="13" width="109" height="32"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="push" title="Close" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="10">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="keyEquivalent" base64-UTF8="YES">
|
||||
Gw
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="close:" target="-2" id="4nd-yJ-c59"/>
|
||||
</connections>
|
||||
</button>
|
||||
<scrollView misplaced="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" id="17">
|
||||
<rect key="frame" x="20" y="186" width="484" height="221"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<clipView key="contentView" id="JQ8-PE-2Fr">
|
||||
<rect key="frame" x="1" y="1" width="467" height="219"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textView importsGraphics="NO" usesFontPanel="YES" findStyle="panel" continuousSpellChecking="YES" usesRuler="YES" spellingCorrection="YES" smartInsertDelete="YES" id="20">
|
||||
<rect key="frame" x="0.0" y="0.0" width="467" height="219"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<size key="minSize" width="467" height="219"/>
|
||||
<size key="maxSize" width="498" height="10000000"/>
|
||||
<attributedString key="textStorage">
|
||||
<fragment>
|
||||
<mutableString key="content">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Et harumd und lookum like Greek to me, dereud facilis est er expedit distinct. Nam liber te conscient to factor tum poen legum odioque civiuda</mutableString>
|
||||
<attributes>
|
||||
<font key="NSFont" size="12" name="LucidaGrande"/>
|
||||
<paragraphStyle key="NSParagraphStyle" alignment="justified" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0" allowsDefaultTighteningForTruncation="NO">
|
||||
<tabStops>
|
||||
<textTab alignment="left" location="0.0">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="56">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="112">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="168">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="224">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="280">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="336">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="392">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="448">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="504">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="560">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="616">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="672">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="728">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="784">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="840">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="896">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="952">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="1008">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="1064">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="1120">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="1176">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="1232">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="1288">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="1344">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="1400">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="1456">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="1512">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="1568">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="1624">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="1680">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="1736">
|
||||
<options/>
|
||||
</textTab>
|
||||
</tabStops>
|
||||
</paragraphStyle>
|
||||
</attributes>
|
||||
</fragment>
|
||||
</attributedString>
|
||||
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
</textView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</clipView>
|
||||
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="19">
|
||||
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="18">
|
||||
<rect key="frame" x="468" y="1" width="15" height="219"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
</scrollView>
|
||||
<button verticalHuggingPriority="750" imageHugsTitle="YES" id="7">
|
||||
<rect key="frame" x="398" y="13" width="118" height="32"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="push" title="Go to Github" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="8">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="keyEquivalent" base64-UTF8="YES">
|
||||
DQ
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="goToGithub:" target="-2" id="se4-ia-8pe"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
</view>
|
||||
<point key="canvasLocation" x="132" y="201.5"/>
|
||||
</window>
|
||||
</objects>
|
||||
</document>
|
68
cocoalib/Base.lproj/about.xib
Normal file
68
cocoalib/Base.lproj/about.xib
Normal file
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="HSAboutBox">
|
||||
<connections>
|
||||
<outlet property="copyrightTextField" destination="9" id="18"/>
|
||||
<outlet property="titleTextField" destination="5" id="16"/>
|
||||
<outlet property="versionTextField" destination="7" id="17"/>
|
||||
<outlet property="window" destination="1" id="15"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application"/>
|
||||
<window allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" deferred="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="1">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="552" y="386" width="259" height="195"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="878"/>
|
||||
<view key="contentView" misplaced="YES" id="2">
|
||||
<rect key="frame" x="0.0" y="0.0" width="259" height="195"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" id="5">
|
||||
<rect key="frame" x="17" y="64" width="225" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" sendsActionOnEndEditing="YES" alignment="center" title="AppTitle" id="6">
|
||||
<font key="font" metaFont="systemBold"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" id="7">
|
||||
<rect key="frame" x="17" y="42" width="225" height="14"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" sendsActionOnEndEditing="YES" alignment="center" title="AppVersion" id="8">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" id="9">
|
||||
<rect key="frame" x="17" y="20" width="225" height="14"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" sendsActionOnEndEditing="YES" alignment="center" title="AppCopyright" id="10">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<imageView misplaced="YES" id="3">
|
||||
<rect key="frame" x="19" y="89" width="219" height="96"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" animates="YES" imageScaling="proportionallyDown" image="NSApplicationIcon" id="4"/>
|
||||
</imageView>
|
||||
</subviews>
|
||||
</view>
|
||||
<point key="canvasLocation" x="131.5" y="150.5"/>
|
||||
</window>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="NSApplicationIcon" width="128" height="128"/>
|
||||
</resources>
|
||||
</document>
|
73
cocoalib/Base.lproj/progress.xib
Normal file
73
cocoalib/Base.lproj/progress.xib
Normal file
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="ProgressController">
|
||||
<connections>
|
||||
<outlet property="cancelButton" destination="10" id="25"/>
|
||||
<outlet property="descText" destination="7" id="30"/>
|
||||
<outlet property="progressBar" destination="8" id="21"/>
|
||||
<outlet property="statusText" destination="9" id="20"/>
|
||||
<outlet property="window" destination="5" id="22"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application"/>
|
||||
<window title="Work in progress..." allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="5" userLabel="Panel" customClass="NSPanel">
|
||||
<windowStyleMask key="styleMask" titled="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="440" y="520" width="323" height="143"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="878"/>
|
||||
<value key="minSize" type="size" width="213" height="107"/>
|
||||
<view key="contentView" id="6">
|
||||
<rect key="frame" x="0.0" y="0.0" width="323" height="143"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" id="7">
|
||||
<rect key="frame" x="17" y="106" width="289" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Work in progress, please wait." id="32">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<progressIndicator verticalHuggingPriority="750" maxValue="100" bezeled="NO" indeterminate="YES" style="bar" id="8">
|
||||
<rect key="frame" x="18" y="78" width="287" height="20"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</progressIndicator>
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" id="9">
|
||||
<rect key="frame" x="17" y="60" width="289" height="14"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Status: Working..." id="33">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button verticalHuggingPriority="750" imageHugsTitle="YES" id="10">
|
||||
<rect key="frame" x="227" y="12" width="82" height="32"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" enabled="NO" refusesFirstResponder="YES" state="on" borderStyle="border" inset="2" id="34">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="keyEquivalent" base64-UTF8="YES">
|
||||
Gw
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="cancel:" target="-2" id="23"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="-2" id="24"/>
|
||||
</connections>
|
||||
</window>
|
||||
</objects>
|
||||
</document>
|
14
cocoalib/Dialogs.h
Normal file
14
cocoalib/Dialogs.h
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface Dialogs : NSObject
|
||||
+ (void)showMessage:(NSString *)message;
|
||||
+ (NSInteger)askYesNo:(NSString *)message;
|
||||
@end
|
31
cocoalib/Dialogs.m
Normal file
31
cocoalib/Dialogs.m
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "Dialogs.h"
|
||||
|
||||
@implementation Dialogs
|
||||
+ (void)showMessage:(NSString *)message
|
||||
{
|
||||
NSAlert *a = [[NSAlert alloc] init];
|
||||
[a addButtonWithTitle:NSLocalizedStringFromTable(@"OK", @"cocoalib", @"")];
|
||||
[a setMessageText:message];
|
||||
[a runModal];
|
||||
[a release];
|
||||
}
|
||||
|
||||
+ (NSInteger)askYesNo:(NSString *)message
|
||||
{
|
||||
NSAlert *a = [[NSAlert alloc] init];
|
||||
[a addButtonWithTitle:NSLocalizedStringFromTable(@"Yes", @"cocoalib", @"")];
|
||||
[[a addButtonWithTitle:NSLocalizedStringFromTable(@"No", @"cocoalib", @"")] setKeyEquivalent:@"\E"];
|
||||
[a setMessageText:message];
|
||||
NSInteger r = [a runModal];
|
||||
[a release];
|
||||
return r;
|
||||
}
|
||||
@end
|
27
cocoalib/HSAboutBox.h
Normal file
27
cocoalib/HSAboutBox.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
Copyright 2017 Virgil Dupras
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "PyBaseApp.h"
|
||||
|
||||
@interface HSAboutBox : NSWindowController
|
||||
{
|
||||
IBOutlet NSTextField *titleTextField;
|
||||
IBOutlet NSTextField *versionTextField;
|
||||
IBOutlet NSTextField *copyrightTextField;
|
||||
|
||||
PyBaseApp *app;
|
||||
}
|
||||
|
||||
@property (readwrite, retain) NSTextField *titleTextField;
|
||||
@property (readwrite, retain) NSTextField *versionTextField;
|
||||
@property (readwrite, retain) NSTextField *copyrightTextField;
|
||||
|
||||
- (id)initWithApp:(PyBaseApp *)app;
|
||||
- (void)updateFields;
|
||||
@end
|
41
cocoalib/HSAboutBox.m
Normal file
41
cocoalib/HSAboutBox.m
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2017 Virgil Dupras
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "HSAboutBox.h"
|
||||
|
||||
@implementation HSAboutBox
|
||||
|
||||
@synthesize titleTextField;
|
||||
@synthesize versionTextField;
|
||||
@synthesize copyrightTextField;
|
||||
|
||||
- (id)initWithApp:(PyBaseApp *)aApp
|
||||
{
|
||||
self = [super initWithWindowNibName:@"about"];
|
||||
[self window];
|
||||
app = [aApp retain];
|
||||
[self updateFields];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[app release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)updateFields
|
||||
{
|
||||
[titleTextField setStringValue:[app appLongName]];
|
||||
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
|
||||
[versionTextField setStringValue:[NSString stringWithFormat:@"Version: %@",version]];
|
||||
NSString *copyright = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSHumanReadableCopyright"];
|
||||
[copyrightTextField setStringValue:copyright];
|
||||
}
|
||||
|
||||
@end
|
26
cocoalib/HSErrorReportWindow.h
Normal file
26
cocoalib/HSErrorReportWindow.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
Copyright 2017 Virgil Dupras
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface HSErrorReportWindow : NSWindowController
|
||||
{
|
||||
IBOutlet NSTextView *contentTextView;
|
||||
NSString *githubUrl;
|
||||
}
|
||||
|
||||
@property (readwrite, retain) NSTextView *contentTextView;
|
||||
@property (readwrite, retain) NSString *githubUrl;
|
||||
|
||||
// True if the user wants to send the report
|
||||
+ (void)showErrorReportWithContent:(NSString *)content githubUrl:(NSString *)githubUrl;
|
||||
- (id)initWithContent:(NSString *)content githubUrl:(NSString *)githubUrl;
|
||||
|
||||
- (IBAction)goToGithub:(id)sender;
|
||||
- (IBAction)close:(id)sender;
|
||||
@end
|
43
cocoalib/HSErrorReportWindow.m
Normal file
43
cocoalib/HSErrorReportWindow.m
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
Copyright 2017 Virgil Dupras
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "HSErrorReportWindow.h"
|
||||
|
||||
@implementation HSErrorReportWindow
|
||||
|
||||
@synthesize contentTextView;
|
||||
@synthesize githubUrl;
|
||||
|
||||
+ (void)showErrorReportWithContent:(NSString *)content githubUrl:(NSString *)githubUrl
|
||||
{
|
||||
HSErrorReportWindow *report = [[HSErrorReportWindow alloc] initWithContent:content githubUrl:githubUrl];
|
||||
[NSApp runModalForWindow:[report window]];
|
||||
[report release];
|
||||
}
|
||||
|
||||
- (id)initWithContent:(NSString *)content githubUrl:(NSString *)aGithubUrl
|
||||
{
|
||||
self = [super initWithWindowNibName:@"ErrorReportWindow"];
|
||||
[self window];
|
||||
[contentTextView alignLeft:nil];
|
||||
[[[contentTextView textStorage] mutableString] setString:content];
|
||||
self.githubUrl = aGithubUrl;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (IBAction)goToGithub:(id)sender
|
||||
{
|
||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:self.githubUrl]];
|
||||
}
|
||||
|
||||
- (IBAction)close:(id)sender
|
||||
{
|
||||
[[self window] orderOut:self];
|
||||
[NSApp stopModalWithCode:NSOKButton];
|
||||
}
|
||||
@end
|
15
cocoalib/HSGeometry.h
Normal file
15
cocoalib/HSGeometry.h
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <math.h>
|
||||
|
||||
CGFloat deg2rad(CGFloat deg);
|
||||
CGFloat distance(NSPoint p1, NSPoint p2);
|
||||
NSPoint pointInCircle(NSPoint center, CGFloat radius, CGFloat angle);
|
||||
CGFloat angleFromPoints(NSPoint pt1, NSPoint pt2);
|
71
cocoalib/HSGeometry.m
Normal file
71
cocoalib/HSGeometry.m
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "HSGeometry.h"
|
||||
|
||||
CGFloat deg2rad(CGFloat deg)
|
||||
{
|
||||
return deg * M_PI / 180;
|
||||
}
|
||||
|
||||
CGFloat distance(NSPoint p1, NSPoint p2)
|
||||
{
|
||||
CGFloat dX = p1.x - p2.x;
|
||||
CGFloat dY = p1.y - p2.y;
|
||||
return sqrt(dX * dX + dY * dY);
|
||||
}
|
||||
|
||||
NSPoint pointInCircle(NSPoint center, CGFloat radius, CGFloat angle)
|
||||
{
|
||||
// a/sin(A) = b/sin(B) = c/sin(C) = 2R
|
||||
// the start point it (center.x + radius, center.y) and goes counterclockwise
|
||||
angle = fmod(angle, M_PI*2);
|
||||
CGFloat C = M_PI/2;
|
||||
CGFloat A = fmod(angle, M_PI/2);
|
||||
CGFloat B = C - A;
|
||||
CGFloat c = radius;
|
||||
CGFloat ratio = c / sin(C);
|
||||
CGFloat b = ratio * sin(B);
|
||||
CGFloat a = ratio * sin(A);
|
||||
if (angle >= M_PI * 1.5)
|
||||
return NSMakePoint(center.x + a, center.y - b);
|
||||
else if (angle >= M_PI)
|
||||
return NSMakePoint(center.x - b, center.y - a);
|
||||
else if (angle >= M_PI/2)
|
||||
return NSMakePoint(center.x - a, center.y + b);
|
||||
else
|
||||
return NSMakePoint(center.x + b, center.y + a);
|
||||
}
|
||||
|
||||
CGFloat angleFromPoints(NSPoint pt1, NSPoint pt2)
|
||||
{
|
||||
// Returns the angle (radian) formed by the line pt1-pt2. The angle follows the same logic
|
||||
// as in pointInCircle.
|
||||
// What we do here is that we take the line and reduce it to fit a "unit circle" (circle with
|
||||
// a radius of 1). Then, either asin(adjusted_dy) or acos(adjusted_dx) will give us our angle.
|
||||
// We'll use asin(adjusted_dy).
|
||||
CGFloat length = distance(pt1, pt2);
|
||||
CGFloat dx = pt2.x - pt1.x;
|
||||
CGFloat dy = pt2.y - pt1.y;
|
||||
CGFloat ajdusted_dy = ABS(dy) / length;
|
||||
CGFloat angle = asin(ajdusted_dy);
|
||||
|
||||
if ((dx < 0) && (dy >= 0)) {
|
||||
// top-left quadrant
|
||||
angle = M_PI - angle;
|
||||
}
|
||||
else if ((dx < 0) && (dy < 0)) {
|
||||
// bottom-left quadrant
|
||||
angle = M_PI + angle;
|
||||
}
|
||||
else if ((dx >= 0) && (dy < 0)) {
|
||||
// bottom-right quadrant
|
||||
angle = (2 * M_PI) - angle;
|
||||
}
|
||||
return angle;
|
||||
}
|
13
cocoalib/HSPyUtil.h
Normal file
13
cocoalib/HSPyUtil.h
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Python.h>
|
||||
|
||||
void setCocoaViewsModuleName(NSString *moduleName);
|
||||
PyObject* createCallback(NSString *aViewClassName, id aViewRef);
|
34
cocoalib/HSPyUtil.m
Normal file
34
cocoalib/HSPyUtil.m
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "HSPyUtil.h"
|
||||
#import "ObjP.h"
|
||||
|
||||
static NSString *gCocoaViewsModuleName;
|
||||
void setCocoaViewsModuleName(NSString *moduleName)
|
||||
{
|
||||
if (gCocoaViewsModuleName != nil) {
|
||||
[gCocoaViewsModuleName release];
|
||||
}
|
||||
gCocoaViewsModuleName = [moduleName retain];
|
||||
}
|
||||
|
||||
PyObject* createCallback(NSString *aViewClassName, id aViewRef)
|
||||
{
|
||||
NSString *moduleName;
|
||||
if (gCocoaViewsModuleName != nil) {
|
||||
moduleName = gCocoaViewsModuleName;
|
||||
}
|
||||
else {
|
||||
moduleName = @"inter.CocoaViews";
|
||||
}
|
||||
PyGILState_STATE gilState = PyGILState_Ensure();
|
||||
PyObject *pCallback = ObjP_classInstanceWithRef(aViewClassName, moduleName, aViewRef);
|
||||
PyGILState_Release(gilState);
|
||||
return pCallback;
|
||||
}
|
18
cocoalib/HSQuicklook.h
Normal file
18
cocoalib/HSQuicklook.h
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Quartz/Quartz.h>
|
||||
|
||||
@interface HSQLPreviewItem : NSObject <QLPreviewItem>
|
||||
{
|
||||
NSURL *url;
|
||||
NSString *title;
|
||||
}
|
||||
- (id)initWithUrl:(NSURL *)aUrl title:(NSString *)aTitle;
|
||||
@end
|
36
cocoalib/HSQuicklook.m
Normal file
36
cocoalib/HSQuicklook.m
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "HSQuicklook.h"
|
||||
|
||||
@implementation HSQLPreviewItem
|
||||
- (id)initWithUrl:(NSURL *)aUrl title:(NSString *)aTitle
|
||||
{
|
||||
self = [super init];
|
||||
url = [aUrl retain];
|
||||
title = [aTitle retain];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[url release];
|
||||
[title release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSURL *)previewItemURL
|
||||
{
|
||||
return url;
|
||||
}
|
||||
|
||||
- (NSString *)previewItemTitle
|
||||
{
|
||||
return title;
|
||||
}
|
||||
@end
|
35
cocoalib/HSRecentFiles.h
Normal file
35
cocoalib/HSRecentFiles.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface HSRecentFiles : NSObject
|
||||
{
|
||||
id delegate;
|
||||
NSMenu *menu;
|
||||
NSString *name;
|
||||
NSMutableArray *filepaths;
|
||||
NSInteger numberOfMenuItemsToPreserve;
|
||||
}
|
||||
- (id)initWithName:(NSString *)aName menu:(NSMenu *)aMenu;
|
||||
|
||||
- (void)addFile:(NSString *)path;
|
||||
- (void)rebuildMenu;
|
||||
- (void)fillMenu:(NSMenu *)menu;
|
||||
- (void)clearMenu:(id)sender;
|
||||
- (void)menuClick:(id)sender;
|
||||
|
||||
- (NSMenu *)menu;
|
||||
- (id)delegate;
|
||||
- (void)setDelegate:(id)aDelegate;
|
||||
- (NSArray *)filepaths;
|
||||
@end
|
||||
|
||||
@protocol HSRecentFilesDelegate
|
||||
- (void)recentFileClicked:(NSString *)path;
|
||||
@end
|
89
cocoalib/HSRecentFiles.m
Normal file
89
cocoalib/HSRecentFiles.m
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "HSRecentFiles.h"
|
||||
|
||||
@implementation HSRecentFiles
|
||||
- (id)initWithName:(NSString *)aName menu:(NSMenu *)aMenu
|
||||
{
|
||||
self = [super init];
|
||||
name = aName;
|
||||
menu = [aMenu retain];
|
||||
numberOfMenuItemsToPreserve = [menu numberOfItems];
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
filepaths = [[NSMutableArray alloc] initWithArray:[ud arrayForKey:name]];
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
for (NSInteger i=[filepaths count]-1;i>=0;i--) {
|
||||
NSString *path = [filepaths objectAtIndex:i];
|
||||
// We check for path class because we might be fed with garbage from the prefs.
|
||||
if ((![path isKindOfClass:[NSString class]]) || (![fm fileExistsAtPath:path])) {
|
||||
[filepaths removeObjectAtIndex:i];
|
||||
}
|
||||
}
|
||||
[self rebuildMenu];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
[ud setObject:filepaths forKey:name];
|
||||
[ud synchronize];
|
||||
[filepaths release];
|
||||
[menu release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)addFile:(NSString *)path
|
||||
{
|
||||
[filepaths removeObject:path];
|
||||
[filepaths insertObject:path atIndex:0];
|
||||
[self rebuildMenu];
|
||||
}
|
||||
|
||||
- (void)rebuildMenu
|
||||
{
|
||||
while ([menu numberOfItems] > numberOfMenuItemsToPreserve)
|
||||
[menu removeItemAtIndex:[menu numberOfItems]-1];
|
||||
[self fillMenu:menu];
|
||||
if ([filepaths count] > 0) {
|
||||
[menu addItem:[NSMenuItem separatorItem]];
|
||||
NSMenuItem *mi = [menu addItemWithTitle:NSLocalizedStringFromTable(@"Clear List", @"cocoalib", @"") action:@selector(clearMenu:) keyEquivalent:@""];
|
||||
[mi setTarget:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)fillMenu:(NSMenu *)menuToFill
|
||||
{
|
||||
for (int i=0;i<[filepaths count];i++) {
|
||||
NSMenuItem *mi = [menuToFill addItemWithTitle:[filepaths objectAtIndex:i] action:@selector(menuClick:) keyEquivalent:@""];
|
||||
[mi setTag:i];
|
||||
[mi setTarget:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)clearMenu:(id)sender
|
||||
{
|
||||
[filepaths removeAllObjects];
|
||||
[self rebuildMenu];
|
||||
}
|
||||
|
||||
- (void)menuClick:(id)sender
|
||||
{
|
||||
if (delegate == nil)
|
||||
return;
|
||||
if ([delegate respondsToSelector:@selector(recentFileClicked:)])
|
||||
[delegate recentFileClicked:[filepaths objectAtIndex:[sender tag]]];
|
||||
}
|
||||
|
||||
/* Properties */
|
||||
- (NSMenu *)menu {return menu;}
|
||||
- (id)delegate { return delegate; }
|
||||
- (void)setDelegate:(id)aDelegate { delegate = aDelegate; }
|
||||
- (NSArray *)filepaths {return filepaths;}
|
||||
@end
|
10
cocoalib/LICENSE
Normal file
10
cocoalib/LICENSE
Normal file
@ -0,0 +1,10 @@
|
||||
Copyright 2014, Hardcoded Software Inc., http://www.hardcoded.net
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Hardcoded Software Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
24
cocoalib/NSEventAdditions.h
Normal file
24
cocoalib/NSEventAdditions.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface NSEvent(NSEventAdditions)
|
||||
- (unichar)firstCharacter;
|
||||
- (NSUInteger)flags;
|
||||
- (NSUInteger)modifierKeysFlags;
|
||||
- (BOOL)isDeleteOrBackspace;
|
||||
- (BOOL)isReturnOrEnter;
|
||||
- (BOOL)isTab;
|
||||
- (BOOL)isBackTab;
|
||||
- (BOOL)isSpace;
|
||||
- (BOOL)isUp;
|
||||
- (BOOL)isDown;
|
||||
- (BOOL)isLeft;
|
||||
- (BOOL)isRight;
|
||||
@end
|
85
cocoalib/NSEventAdditions.m
Normal file
85
cocoalib/NSEventAdditions.m
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "NSEventAdditions.h"
|
||||
|
||||
@implementation NSEvent(NSEventAdditions)
|
||||
|
||||
- (unichar)firstCharacter
|
||||
{
|
||||
NSString *characters = [self characters];
|
||||
if ([characters length] == 0)
|
||||
{
|
||||
return '\0';
|
||||
}
|
||||
return [characters characterAtIndex:0];
|
||||
}
|
||||
|
||||
- (NSUInteger)flags
|
||||
{
|
||||
// get flags and strip the lower 16 (device dependant) bits
|
||||
// See modifierFlags's doc for details
|
||||
return [self modifierFlags] & NSDeviceIndependentModifierFlagsMask;
|
||||
}
|
||||
|
||||
- (NSUInteger)modifierKeysFlags
|
||||
{
|
||||
// This is modifierFlags with only Command, Opt, Ctrl and Shift, without the rest of the flags
|
||||
// to pollute.
|
||||
return [self flags] & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask);
|
||||
}
|
||||
|
||||
- (BOOL)isDeleteOrBackspace
|
||||
{
|
||||
unichar firstChar = [self firstCharacter];
|
||||
return firstChar == NSDeleteFunctionKey || firstChar == NSDeleteCharFunctionKey ||
|
||||
firstChar == NSDeleteCharacter || firstChar == NSBackspaceCharacter;
|
||||
}
|
||||
|
||||
- (BOOL)isReturnOrEnter
|
||||
{
|
||||
unichar firstChar = [self firstCharacter];
|
||||
return firstChar == NSCarriageReturnCharacter || firstChar == NSEnterCharacter;
|
||||
}
|
||||
|
||||
- (BOOL)isTab
|
||||
{
|
||||
return [self firstCharacter] == NSTabCharacter;
|
||||
}
|
||||
|
||||
- (BOOL)isBackTab
|
||||
{
|
||||
return [self firstCharacter] == NSBackTabCharacter;
|
||||
}
|
||||
|
||||
- (BOOL)isSpace
|
||||
{
|
||||
return ([self firstCharacter] == 0x20) && (![self flags]);
|
||||
}
|
||||
|
||||
- (BOOL)isUp
|
||||
{
|
||||
return [self firstCharacter] == NSUpArrowFunctionKey;
|
||||
}
|
||||
|
||||
- (BOOL)isDown
|
||||
{
|
||||
return [self firstCharacter] == NSDownArrowFunctionKey;
|
||||
}
|
||||
|
||||
- (BOOL)isLeft
|
||||
{
|
||||
return [self firstCharacter] == NSLeftArrowFunctionKey;
|
||||
}
|
||||
|
||||
- (BOOL)isRight
|
||||
{
|
||||
return [self firstCharacter] == NSRightArrowFunctionKey;
|
||||
}
|
||||
|
||||
@end
|
21
cocoalib/NSImageAdditions.h
Normal file
21
cocoalib/NSImageAdditions.h
Normal file
@ -0,0 +1,21 @@
|
||||
// Created by Scott Stevenson on 9/28/07.
|
||||
//
|
||||
// Personal site: http://theocacao.com/
|
||||
// Post for this sample: http://theocacao.com/document.page/497
|
||||
//
|
||||
// The code in this project is intended to be used as a learning
|
||||
// tool for Cocoa programmers. You may freely use the code in
|
||||
// your own programs, but please do not use the code as-is in
|
||||
// other tutorials.
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
|
||||
@interface NSImage (Extras)
|
||||
|
||||
// creates a copy of the current image while maintaining
|
||||
// proportions. also centers image, if necessary
|
||||
|
||||
- (NSImage*)imageByScalingProportionallyToSize:(NSSize)aSize;
|
||||
|
||||
@end
|
114
cocoalib/NSImageAdditions.m
Normal file
114
cocoalib/NSImageAdditions.m
Normal file
@ -0,0 +1,114 @@
|
||||
// Created by Scott Stevenson on 9/28/07.
|
||||
//
|
||||
// Personal site: http://theocacao.com/
|
||||
// Post for this sample: http://theocacao.com/document.page/497
|
||||
//
|
||||
// The code in this project is intended to be used as a learning
|
||||
// tool for Cocoa programmers. You may freely use the code in
|
||||
// your own programs, but please do not use the code as-is in
|
||||
// other tutorials.
|
||||
|
||||
#import "NSImageAdditions.h"
|
||||
|
||||
|
||||
@implementation NSImage (Extras)
|
||||
|
||||
- (NSImage*)imageByScalingProportionallyToSize:(NSSize)targetSize
|
||||
{
|
||||
NSImage* sourceImage = self;
|
||||
NSImage* newImage = nil;
|
||||
|
||||
if ([sourceImage isValid])
|
||||
{
|
||||
NSSize imageSize = [sourceImage size];
|
||||
CGFloat width = imageSize.width;
|
||||
CGFloat height = imageSize.height;
|
||||
|
||||
CGFloat targetWidth = targetSize.width;
|
||||
CGFloat targetHeight = targetSize.height;
|
||||
|
||||
// scaleFactor will be the fraction that we'll
|
||||
// use to adjust the size. For example, if we shrink
|
||||
// an image by half, scaleFactor will be 0.5. the
|
||||
// scaledWidth and scaledHeight will be the original,
|
||||
// multiplied by the scaleFactor.
|
||||
//
|
||||
// IMPORTANT: the "targetHeight" is the size of the space
|
||||
// we're drawing into. The "scaledHeight" is the height that
|
||||
// the image actually is drawn at, once we take into
|
||||
// account the ideal of maintaining proportions
|
||||
|
||||
CGFloat scaleFactor = 0.0;
|
||||
CGFloat scaledWidth = targetWidth;
|
||||
CGFloat scaledHeight = targetHeight;
|
||||
|
||||
NSPoint thumbnailPoint = NSMakePoint(0,0);
|
||||
|
||||
// since not all images are square, we want to scale
|
||||
// proportionately. To do this, we find the longest
|
||||
// edge and use that as a guide.
|
||||
|
||||
if ( NSEqualSizes( imageSize, targetSize ) == NO )
|
||||
{
|
||||
// use the longeset edge as a guide. if the
|
||||
// image is wider than tall, we'll figure out
|
||||
// the scale factor by dividing it by the
|
||||
// intended width. Otherwise, we'll use the
|
||||
// height.
|
||||
|
||||
CGFloat widthFactor = targetWidth / width;
|
||||
CGFloat heightFactor = targetHeight / height;
|
||||
|
||||
if ( widthFactor < heightFactor )
|
||||
scaleFactor = widthFactor;
|
||||
else
|
||||
scaleFactor = heightFactor;
|
||||
|
||||
// ex: 500 * 0.5 = 250 (newWidth)
|
||||
|
||||
scaledWidth = width * scaleFactor;
|
||||
scaledHeight = height * scaleFactor;
|
||||
|
||||
// center the thumbnail in the frame. if
|
||||
// wider than tall, we need to adjust the
|
||||
// vertical drawing point (y axis)
|
||||
|
||||
if ( widthFactor < heightFactor )
|
||||
thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5;
|
||||
|
||||
else if ( widthFactor > heightFactor )
|
||||
thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5;
|
||||
}
|
||||
|
||||
|
||||
// create a new image to draw into
|
||||
newImage = [[NSImage alloc] initWithSize:targetSize];
|
||||
|
||||
// once focus is locked, all drawing goes into this NSImage instance
|
||||
// directly, not to the screen. It also receives its own graphics
|
||||
// context.
|
||||
//
|
||||
// Also, keep in mind that we're doing this in a background thread.
|
||||
// You only want to draw to the screen in the main thread, but
|
||||
// drawing to an offscreen image is (apparently) okay.
|
||||
|
||||
[newImage lockFocus];
|
||||
|
||||
NSRect thumbnailRect;
|
||||
thumbnailRect.origin = thumbnailPoint;
|
||||
thumbnailRect.size.width = scaledWidth;
|
||||
thumbnailRect.size.height = scaledHeight;
|
||||
|
||||
[sourceImage drawInRect: thumbnailRect
|
||||
fromRect: NSZeroRect
|
||||
operation: NSCompositeSourceOver
|
||||
fraction: 1.0];
|
||||
|
||||
[newImage unlockFocus];
|
||||
|
||||
}
|
||||
|
||||
return [newImage autorelease];
|
||||
}
|
||||
|
||||
@end
|
10
cocoalib/NSNotificationAdditions.h
Normal file
10
cocoalib/NSNotificationAdditions.h
Normal file
@ -0,0 +1,10 @@
|
||||
// from http://www.cocoadev.com/index.pl?NotificationsAcrossThreads
|
||||
#import <Cocoa/Cocoa.h>
|
||||
@interface NSNotificationCenter (NSNotificationCenterAdditions)
|
||||
- (void) postNotificationOnMainThread:(NSNotification *) notification;
|
||||
- (void) postNotificationOnMainThread:(NSNotification *) notification waitUntilDone:(BOOL) wait;
|
||||
|
||||
- (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object;
|
||||
- (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object userInfo:(NSDictionary *) userInfo;
|
||||
- (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object userInfo:(NSDictionary *) userInfo waitUntilDone:(BOOL) wait;
|
||||
@end
|
48
cocoalib/NSNotificationAdditions.m
Normal file
48
cocoalib/NSNotificationAdditions.m
Normal file
@ -0,0 +1,48 @@
|
||||
#import "NSNotificationAdditions.h"
|
||||
#import <pthread.h>
|
||||
|
||||
@implementation NSNotificationCenter (NSNotificationCenterAdditions)
|
||||
- (void) postNotificationOnMainThread:(NSNotification *) notification {
|
||||
if( pthread_main_np() ) return [self postNotification:notification];
|
||||
[self postNotificationOnMainThread:notification waitUntilDone:NO];
|
||||
}
|
||||
|
||||
- (void) postNotificationOnMainThread:(NSNotification *) notification waitUntilDone:(BOOL) wait {
|
||||
if( pthread_main_np() ) return [self postNotification:notification];
|
||||
[[self class] performSelectorOnMainThread:@selector( _postNotification: ) withObject:notification waitUntilDone:wait];
|
||||
}
|
||||
|
||||
+ (void) _postNotification:(NSNotification *) notification {
|
||||
[[self defaultCenter] postNotification:notification];
|
||||
}
|
||||
|
||||
- (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object {
|
||||
if( pthread_main_np() ) return [self postNotificationName:name object:object userInfo:nil];
|
||||
[self postNotificationOnMainThreadWithName:name object:object userInfo:nil waitUntilDone:NO];
|
||||
}
|
||||
|
||||
- (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object userInfo:(NSDictionary *) userInfo {
|
||||
if( pthread_main_np() ) return [self postNotificationName:name object:object userInfo:userInfo];
|
||||
[self postNotificationOnMainThreadWithName:name object:object userInfo:nil waitUntilDone:NO];
|
||||
}
|
||||
|
||||
- (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object userInfo:(NSDictionary *) userInfo waitUntilDone:(BOOL) wait {
|
||||
if( pthread_main_np() ) return [self postNotificationName:name object:object userInfo:userInfo];
|
||||
|
||||
NSMutableDictionary *info = [[NSMutableDictionary allocWithZone:nil] init];
|
||||
[info setObject:name forKey:@"name"];
|
||||
if( object ) [info setObject:object forKey:@"object"];
|
||||
if( userInfo ) [info setObject:userInfo forKey:@"userInfo"];
|
||||
|
||||
[[self class] performSelectorOnMainThread:@selector( _postNotificationName: ) withObject:info waitUntilDone:wait];
|
||||
[info release];
|
||||
}
|
||||
|
||||
+ (void) _postNotificationName:(NSDictionary *) info {
|
||||
NSString *name = [info objectForKey:@"name"];
|
||||
id object = [info objectForKey:@"object"];
|
||||
NSDictionary *userInfo = [info objectForKey:@"userInfo"];
|
||||
|
||||
[[self defaultCenter] postNotificationName:name object:object userInfo:userInfo];
|
||||
}
|
||||
@end
|
50
cocoalib/ProgressController.h
Normal file
50
cocoalib/ProgressController.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "Worker.h"
|
||||
|
||||
extern NSString *JobCompletedNotification;
|
||||
extern NSString *JobCancelledNotification;
|
||||
|
||||
@interface ProgressController : NSWindowController <NSWindowDelegate>
|
||||
{
|
||||
IBOutlet NSButton *cancelButton;
|
||||
IBOutlet NSProgressIndicator *progressBar;
|
||||
IBOutlet NSTextField *statusText;
|
||||
IBOutlet NSTextField *descText;
|
||||
|
||||
id _jobId;
|
||||
BOOL _running;
|
||||
NSObject<Worker> *_worker;
|
||||
}
|
||||
|
||||
@property (readwrite, retain) NSButton *cancelButton;
|
||||
@property (readwrite, retain) NSProgressIndicator *progressBar;
|
||||
@property (readwrite, retain) NSTextField *statusText;
|
||||
@property (readwrite, retain) NSTextField *descText;
|
||||
|
||||
+ (ProgressController *)mainProgressController;
|
||||
|
||||
- (id)init;
|
||||
|
||||
- (IBAction)cancel:(id)sender;
|
||||
|
||||
- (void)hide;
|
||||
- (void)show;
|
||||
- (void)showWithCancelButton:(BOOL)cancelEnabled;
|
||||
- (void)showSheetForParent:(NSWindow *) parentWindow;
|
||||
- (void)showSheetForParent:(NSWindow *) parentWindow withCancelButton:(BOOL)cancelEnabled;
|
||||
|
||||
/* Properties */
|
||||
- (BOOL)isShown;
|
||||
- (id)jobId;
|
||||
- (void)setJobId:(id)jobId;
|
||||
- (void)setJobDesc:(NSString *)desc;
|
||||
- (void)setWorker:(NSObject<Worker> *)worker;
|
||||
@end
|
159
cocoalib/ProgressController.m
Normal file
159
cocoalib/ProgressController.m
Normal file
@ -0,0 +1,159 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "ProgressController.h"
|
||||
#import "Utils.h"
|
||||
|
||||
NSString *JobCompletedNotification = @"JobCompletedNotification";
|
||||
NSString *JobCancelledNotification = @"JobCancelledNotification";
|
||||
static ProgressController *_mainPC = nil;
|
||||
|
||||
@implementation ProgressController
|
||||
|
||||
@synthesize cancelButton;
|
||||
@synthesize progressBar;
|
||||
@synthesize statusText;
|
||||
@synthesize descText;
|
||||
|
||||
+ (ProgressController *)mainProgressController
|
||||
{
|
||||
if (_mainPC == nil)
|
||||
_mainPC = [[ProgressController alloc] init];
|
||||
return _mainPC;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super initWithWindowNibName:@"progress"];
|
||||
[self window];
|
||||
[progressBar setUsesThreadedAnimation:YES];
|
||||
_worker = nil;
|
||||
_running = NO;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:nil];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (IBAction)cancel:(id)sender
|
||||
{
|
||||
[self hide];
|
||||
}
|
||||
|
||||
- (void)hide
|
||||
{
|
||||
if (_worker != nil)
|
||||
[_worker cancelJob];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:JobCancelledNotification object:self];
|
||||
_running = NO;
|
||||
[NSApp endSheet:[self window] returnCode:NSRunAbortedResponse];
|
||||
/* There's this really strange thing where when the app is inactive at the point we want to hide
|
||||
the progress dialog, it becomes impossible to close it. I guess it's due to some strange
|
||||
thread-related crap. Anyway, *DO NOT HIDE THE SHEET WHILE THE APP IS INACTIVE*. Do it later,
|
||||
when the app becomes active again.
|
||||
*/
|
||||
if ([NSApp isActive]) {
|
||||
[[self window] orderOut:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)show
|
||||
{
|
||||
[self showWithCancelButton:YES];
|
||||
}
|
||||
|
||||
- (void)showWithCancelButton:(BOOL)cancelEnabled
|
||||
{
|
||||
[progressBar setIndeterminate:YES];
|
||||
[[self window] makeKeyAndOrderFront:nil];
|
||||
[progressBar setUsesThreadedAnimation:YES];
|
||||