Merge pull request #72 from nevack/nevack/preferences-revamp

Use SF Symbols in Preferences on Big Sur.
CQTexperiment
Christopher Snowhill 2021-01-07 23:24:44 -08:00 committed by GitHub
commit 5a1c398291
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 341 additions and 324 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15400" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies> <dependencies>
<deployment identifier="macosx"/> <deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15400"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
@ -13,6 +13,7 @@
<outlet property="hotKeyPane" destination="6" id="14"/> <outlet property="hotKeyPane" destination="6" id="14"/>
<outlet property="iTunesStyleCheck" destination="AIz-WH-Wqk" id="2n1-pY-cZR"/> <outlet property="iTunesStyleCheck" destination="AIz-WH-Wqk" id="2n1-pY-cZR"/>
<outlet property="midiPane" destination="i5B-ga-Atm" id="rbe-uK-5n2"/> <outlet property="midiPane" destination="i5B-ga-Atm" id="rbe-uK-5n2"/>
<outlet property="notificationsView" destination="U4w-jw-ca5" id="wVJ-GH-A21"/>
<outlet property="outputPane" destination="57" id="75"/> <outlet property="outputPane" destination="57" id="75"/>
<outlet property="playlistView" destination="231" id="244"/> <outlet property="playlistView" destination="231" id="244"/>
<outlet property="scrobblerView" destination="0nK-XQ-5MY" id="dFj-Pk-FCG"/> <outlet property="scrobblerView" destination="0nK-XQ-5MY" id="dFj-Pk-FCG"/>
@ -21,6 +22,95 @@
</customObject> </customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="231" userLabel="PlaylistView">
<rect key="frame" x="0.0" y="0.0" width="530" height="139"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="310">
<rect key="frame" x="18" y="35" width="395" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Read CUE sheets when adding folders to playlist" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="311">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="52" name="value" keyPath="values.readCueSheetsInFolders" id="328"/>
</connections>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="261">
<rect key="frame" x="17" y="59" width="138" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="left" title="When opening file with ⇧ or ⌃⌘ held:" id="262">
<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" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="259">
<rect key="frame" x="17" y="102" width="129" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="When opening files:" id="260">
<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>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="253">
<rect key="frame" x="157" y="63" width="257" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" inset="2" id="254">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="255">
<items>
<menuItem title="Item 1" id="256"/>
<menuItem title="Item 2" id="257"/>
<menuItem title="Item 3" id="258"/>
</items>
</menu>
</popUpButtonCell>
<connections>
<binding destination="246" name="content" keyPath="arrangedObjects" id="264"/>
<binding destination="246" name="contentValues" keyPath="arrangedObjects.name" previousBinding="307" id="308"/>
<binding destination="246" name="contentObjects" keyPath="arrangedObjects.preference" previousBinding="264" id="307"/>
<binding destination="52" name="selectedObject" keyPath="values.openingFilesAlteredBehavior" previousBinding="308" id="309"/>
</connections>
</popUpButton>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="247">
<rect key="frame" x="157" y="95" width="257" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" selectedItem="250" id="248">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="249">
<items>
<menuItem title="Item 1" state="on" id="250"/>
<menuItem title="Item 2" id="251"/>
<menuItem title="Item 3" id="252"/>
</items>
</menu>
</popUpButtonCell>
<connections>
<binding destination="246" name="content" keyPath="arrangedObjects" id="263"/>
<binding destination="246" name="contentValues" keyPath="arrangedObjects.name" previousBinding="304" id="305"/>
<binding destination="246" name="contentObjects" keyPath="arrangedObjects.preference" previousBinding="263" id="304"/>
<binding destination="52" name="selectedObject" keyPath="values.openingFilesBehavior" previousBinding="305" id="306"/>
</connections>
</popUpButton>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6QS-GF-Vnc">
<rect key="frame" x="18" y="15" width="388" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Resume playback on startup" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="fUg-Cg-gXa">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="52" name="value" keyPath="values.resumePlaybackOnStartup" id="8OB-tj-Hd0"/>
</connections>
</button>
</subviews>
<point key="canvasLocation" x="-151" y="-239"/>
</customView>
<customObject id="6" userLabel="HotKeyPane" customClass="HotKeyPane"> <customObject id="6" userLabel="HotKeyPane" customClass="HotKeyPane">
<connections> <connections>
<outlet property="nextHotKeyControl" destination="28" id="36"/> <outlet property="nextHotKeyControl" destination="28" id="36"/>
@ -31,7 +121,7 @@
</connections> </connections>
</customObject> </customObject>
<customView id="11" userLabel="HotKeyView"> <customView id="11" userLabel="HotKeyView">
<rect key="frame" x="0.0" y="0.0" width="500" height="131"/> <rect key="frame" x="0.0" y="0.0" width="530" height="131"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<textField verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="28" customClass="HotKeyControl"> <textField verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="28" customClass="HotKeyControl">
@ -119,10 +209,10 @@
</textFieldCell> </textFieldCell>
</textField> </textField>
</subviews> </subviews>
<point key="canvasLocation" x="123" y="139"/> <point key="canvasLocation" x="-151" y="-33"/>
</customView> </customView>
<customView id="50" userLabel="UpdatesView"> <customView id="50" userLabel="UpdatesView">
<rect key="frame" x="0.0" y="0.0" width="500" height="82"/> <rect key="frame" x="0.0" y="0.0" width="530" height="82"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="111"> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="111">
@ -139,7 +229,7 @@
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" id="208"> <popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" id="208">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="107"> <menu key="menu" title="OtherViews" id="107">
<items> <items>
<menuItem title="Stable" id="108"/> <menuItem title="Stable" id="108"/>
@ -167,6 +257,7 @@
</connections> </connections>
</button> </button>
</subviews> </subviews>
<point key="canvasLocation" x="-151" y="153"/>
</customView> </customView>
<userDefaultsController representsSharedInstance="YES" id="52" userLabel="Shared Defaults"/> <userDefaultsController representsSharedInstance="YES" id="52" userLabel="Shared Defaults"/>
<customObject id="57" userLabel="OutputPane" customClass="OutputPane"> <customObject id="57" userLabel="OutputPane" customClass="OutputPane">
@ -176,7 +267,7 @@
</connections> </connections>
</customObject> </customObject>
<customView id="58" userLabel="OutputView"> <customView id="58" userLabel="OutputView">
<rect key="frame" x="0.0" y="0.0" width="500" height="103"/> <rect key="frame" x="0.0" y="0.0" width="530" height="103"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="65"> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="65">
@ -193,7 +284,7 @@
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<popUpButtonCell key="cell" type="push" title="Item1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" selectedItem="62" id="210"> <popUpButtonCell key="cell" type="push" title="Item1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" selectedItem="62" id="210">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="61"> <menu key="menu" title="OtherViews" id="61">
<items> <items>
<menuItem title="Item1" state="on" id="62"/> <menuItem title="Item1" state="on" id="62"/>
@ -223,7 +314,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="vmS-eb-zen"> <popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="vmS-eb-zen">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="V8o-Xy-HUW"> <menu key="menu" title="OtherViews" id="V8o-Xy-HUW">
<items> <items>
<menuItem title="Item 1" id="oWh-lD-mFH"/> <menuItem title="Item 1" id="oWh-lD-mFH"/>
@ -240,6 +331,7 @@
</connections> </connections>
</popUpButton> </popUpButton>
</subviews> </subviews>
<point key="canvasLocation" x="-151" y="322"/>
</customView> </customView>
<customObject id="i5B-ga-Atm" userLabel="MIDIPane" customClass="MIDIPane"> <customObject id="i5B-ga-Atm" userLabel="MIDIPane" customClass="MIDIPane">
<connections> <connections>
@ -273,7 +365,7 @@
</declaredKeys> </declaredKeys>
</arrayController> </arrayController>
<customView id="0nK-XQ-5MY" userLabel="ScrobblerView"> <customView id="0nK-XQ-5MY" userLabel="ScrobblerView">
<rect key="frame" x="0.0" y="0.0" width="500" height="94"/> <rect key="frame" x="0.0" y="0.0" width="530" height="94"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3gi-0d-78Z"> <button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3gi-0d-78Z">
@ -310,98 +402,10 @@
</connections> </connections>
</button> </button>
</subviews> </subviews>
<point key="canvasLocation" x="450" y="-262"/>
</customView> </customView>
<customView id="231" userLabel="PlaylistView"> <customView id="U4w-jw-ca5" userLabel="NotificationsView">
<rect key="frame" x="0.0" y="0.0" width="500" height="139"/> <rect key="frame" x="0.0" y="0.0" width="530" height="94"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="310">
<rect key="frame" x="18" y="35" width="395" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Read CUE sheets when adding folders to playlist" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="311">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="52" name="value" keyPath="values.readCueSheetsInFolders" id="328"/>
</connections>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="261">
<rect key="frame" x="17" y="59" width="138" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="left" title="When opening file with ⇧ or ⌃⌘ held:" id="262">
<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" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="259">
<rect key="frame" x="17" y="102" width="129" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="When opening files:" id="260">
<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>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="253">
<rect key="frame" x="157" y="63" width="257" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" inset="2" id="254">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<menu key="menu" title="OtherViews" id="255">
<items>
<menuItem title="Item 1" id="256"/>
<menuItem title="Item 2" id="257"/>
<menuItem title="Item 3" id="258"/>
</items>
</menu>
</popUpButtonCell>
<connections>
<binding destination="246" name="content" keyPath="arrangedObjects" id="264"/>
<binding destination="246" name="contentValues" keyPath="arrangedObjects.name" previousBinding="307" id="308"/>
<binding destination="246" name="contentObjects" keyPath="arrangedObjects.preference" previousBinding="264" id="307"/>
<binding destination="52" name="selectedObject" keyPath="values.openingFilesAlteredBehavior" previousBinding="308" id="309"/>
</connections>
</popUpButton>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="247">
<rect key="frame" x="157" y="95" width="257" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" selectedItem="250" id="248">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<menu key="menu" title="OtherViews" id="249">
<items>
<menuItem title="Item 1" state="on" id="250"/>
<menuItem title="Item 2" id="251"/>
<menuItem title="Item 3" id="252"/>
</items>
</menu>
</popUpButtonCell>
<connections>
<binding destination="246" name="content" keyPath="arrangedObjects" id="263"/>
<binding destination="246" name="contentValues" keyPath="arrangedObjects.name" previousBinding="304" id="305"/>
<binding destination="246" name="contentObjects" keyPath="arrangedObjects.preference" previousBinding="263" id="304"/>
<binding destination="52" name="selectedObject" keyPath="values.openingFilesBehavior" previousBinding="305" id="306"/>
</connections>
</popUpButton>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6QS-GF-Vnc">
<rect key="frame" x="18" y="15" width="388" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Resume playback on startup" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="fUg-Cg-gXa">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="52" name="value" keyPath="values.resumePlaybackOnStartup" id="8OB-tj-Hd0"/>
</connections>
</button>
</subviews>
<point key="canvasLocation" x="-78" y="-31.5"/>
</customView>
<customView id="U4w-jw-ca5" userLabel="GrowlView">
<rect key="frame" x="0.0" y="0.0" width="500" height="94"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="njn-Xl-9k9"> <button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="njn-Xl-9k9">
@ -438,10 +442,10 @@
</connections> </connections>
</button> </button>
</subviews> </subviews>
<point key="canvasLocation" x="348" y="132"/> <point key="canvasLocation" x="450" y="-52"/>
</customView> </customView>
<customView id="CgN-sy-RmM" userLabel="AppearanceView"> <customView id="CgN-sy-RmM" userLabel="AppearanceView">
<rect key="frame" x="0.0" y="0.0" width="500" height="54"/> <rect key="frame" x="0.0" y="0.0" width="530" height="54"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="haX-dq-OIe"> <button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="haX-dq-OIe">
@ -456,9 +460,10 @@
</connections> </connections>
</button> </button>
</subviews> </subviews>
<point key="canvasLocation" x="450" y="139"/>
</customView> </customView>
<customView wantsLayer="YES" id="JXu-ar-J3Y" userLabel="MIDIView"> <customView wantsLayer="YES" id="JXu-ar-J3Y" userLabel="MIDIView">
<rect key="frame" x="0.0" y="0.0" width="500" height="137"/> <rect key="frame" x="0.0" y="0.0" width="530" height="137"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews> <subviews>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="SBO-WF-DVS" userLabel="Push Button - Select a SoundFont"> <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="SBO-WF-DVS" userLabel="Push Button - Select a SoundFont">
@ -521,7 +526,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="vaQ-pZ-jXy" id="xcv-1b-kTI"> <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="vaQ-pZ-jXy" id="xcv-1b-kTI">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="menu"/>
<menu key="menu" id="pRc-b6-sMR"> <menu key="menu" id="pRc-b6-sMR">
<items> <items>
<menuItem title="Item 1" state="on" id="vaQ-pZ-jXy"/> <menuItem title="Item 1" state="on" id="vaQ-pZ-jXy"/>
@ -551,7 +556,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" enabled="NO" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" autoenablesItems="NO" altersStateOfSelectedItem="NO" selectedItem="XzK-h2-vIT" id="qzt-Ox-taI"> <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" enabled="NO" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" autoenablesItems="NO" altersStateOfSelectedItem="NO" selectedItem="XzK-h2-vIT" id="qzt-Ox-taI">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="menu"/>
<menu key="menu" autoenablesItems="NO" id="q1g-E5-NwQ"> <menu key="menu" autoenablesItems="NO" id="q1g-E5-NwQ">
<items> <items>
<menuItem title="Item 1" id="XzK-h2-vIT"/> <menuItem title="Item 1" id="XzK-h2-vIT"/>
@ -577,7 +582,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="3Gx-cs-3B0" id="5q7-83-7V6"> <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="3Gx-cs-3B0" id="5q7-83-7V6">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="HKM-FW-dhH"> <menu key="menu" title="OtherViews" id="HKM-FW-dhH">
<items> <items>
<menuItem title="Item 1" state="on" id="3Gx-cs-3B0"/> <menuItem title="Item 1" state="on" id="3Gx-cs-3B0"/>
@ -594,7 +599,7 @@
</connections> </connections>
</popUpButton> </popUpButton>
</subviews> </subviews>
<point key="canvasLocation" x="340" y="567.5"/> <point key="canvasLocation" x="450" y="339"/>
</customView> </customView>
<arrayController objectClassName="NSDictionary" editable="NO" id="JB6-r9-XpG" userLabel="ResamplerBehavior" customClass="ResamplerBehaviorArrayController"> <arrayController objectClassName="NSDictionary" editable="NO" id="JB6-r9-XpG" userLabel="ResamplerBehavior" customClass="ResamplerBehaviorArrayController">
<declaredKeys> <declaredKeys>

View File

@ -10,16 +10,17 @@
#import "PreferencePanePlugin.h" #import "PreferencePanePlugin.h"
@interface GeneralPreferencePane : NSObject <PreferencePane> { @interface GeneralPreferencePane : NSObject <PreferencePane> {
IBOutlet NSView *view; IBOutlet NSView *view;
NSString *title;
NSImage *icon;
} }
+ (GeneralPreferencePane *)preferencePaneWithView:(NSView *)v title:(NSString *)t iconNamed:(NSString *)i; + (instancetype)preferencePaneWithView:(NSView *)view
title:(NSString *)title
systemIconName:(NSString *)systemIconName
orOldIconNamed:(NSString *)oldIconName;
- (void)setView:(NSView *)v; - (instancetype) init NS_UNAVAILABLE;
- (void)setTitle:(NSString *)t; - (instancetype) initWithView:(NSView *)contentView
- (void)setIcon:(NSImage *)i; title:(NSString *)title
icon:(NSImage *)image NS_DESIGNATED_INITIALIZER;
@end @end

View File

@ -11,49 +11,39 @@
@implementation GeneralPreferencePane @implementation GeneralPreferencePane
+ (GeneralPreferencePane *)preferencePaneWithView:(NSView *)v title:(NSString *)t iconNamed:(NSString *)n @synthesize title = _title;
{ @synthesize icon = _icon;
GeneralPreferencePane *pane = [[GeneralPreferencePane alloc] init]; @synthesize view;
if (pane)
{
[pane setView:v];
[pane setTitle:t];
NSImage *i = [[NSImage alloc] initWithContentsOfFile:[[NSBundle bundleForClass:[self class]] pathForImageResource:n]]; + (instancetype)preferencePaneWithView:(NSView *)view
[pane setIcon:i]; title:(NSString *)title
} systemIconName:(NSString *)systemIconName
orOldIconNamed:(NSString *)oldIconName
return pane; {
NSImage *icon;
if (@available(macOS 11.0, *))
{
if (systemIconName)
icon = [NSImage imageWithSystemSymbolName:systemIconName accessibilityDescription:nil];
}
if (icon == nil)
{
NSString *file = [[NSBundle bundleForClass:[self class]] pathForImageResource:oldIconName];
icon = [[NSImage alloc] initWithContentsOfFile:file];
}
return [[GeneralPreferencePane alloc] initWithView:view title:title icon:icon];
} }
- (NSView *)view - (instancetype)initWithView:(NSView *)contentView title:(NSString *)title icon:(NSImage *)image {
{ self = [[[self class] alloc] init];
return view; if (self)
} {
view = contentView;
- (NSString *)title _title = title;
{ _icon = image;
return title; }
} return self;
- (NSImage *)icon
{
return icon;
}
- (void)setView:(NSView *)v
{
view = v;
}
- (void)setTitle:(NSString *)t
{
title = t;
}
- (void)setIcon:(NSImage *)i
{
icon = i;
} }
@end @end

View File

@ -15,17 +15,16 @@
#import "MIDIPane.h" #import "MIDIPane.h"
@interface GeneralPreferencesPlugin : NSObject <PreferencePanePlugin> { @interface GeneralPreferencesPlugin : NSObject <PreferencePanePlugin> {
IBOutlet HotKeyPane *hotKeyPane; IBOutlet HotKeyPane *hotKeyPane;
IBOutlet OutputPane *outputPane; IBOutlet OutputPane *outputPane;
IBOutlet MIDIPane *midiPane; IBOutlet MIDIPane *midiPane;
IBOutlet NSView *playlistView;
IBOutlet NSView *scrobblerView;
IBOutlet NSView *updatesView;
IBOutlet NSView *growlView;
IBOutlet NSView *appearanceView;
IBOutlet NSView *midiView;
IBOutlet NSView *playlistView;
IBOutlet NSView *scrobblerView;
IBOutlet NSView *updatesView;
IBOutlet NSView *notificationsView;
IBOutlet NSView *appearanceView;
__weak IBOutlet NSButton *iTunesStyleCheck; __weak IBOutlet NSButton *iTunesStyleCheck;
} }
@ -36,7 +35,7 @@
- (GeneralPreferencePane *)updatesPane; - (GeneralPreferencePane *)updatesPane;
- (GeneralPreferencePane *)scrobblerPane; - (GeneralPreferencePane *)scrobblerPane;
- (GeneralPreferencePane *)playlistPane; - (GeneralPreferencePane *)playlistPane;
- (GeneralPreferencePane *)growlPane; - (GeneralPreferencePane *)notificationsPane;
- (GeneralPreferencePane *)appearancePane; - (GeneralPreferencePane *)appearancePane;

View File

@ -25,28 +25,28 @@
+ (NSArray *)preferencePanes + (NSArray *)preferencePanes
{ {
GeneralPreferencesPlugin *plugin = [[GeneralPreferencesPlugin alloc] init]; GeneralPreferencesPlugin *plugin = [[GeneralPreferencesPlugin alloc] init];
[NSBundle loadNibNamed:@"Preferences" owner:plugin]; [[NSBundle bundleWithIdentifier:@"org.cogx.cog.preferences"] loadNibNamed:@"Preferences"
owner:plugin
return [NSArray arrayWithObjects: topLevelObjects:nil];
[plugin playlistPane],
[plugin hotKeyPane], return @[[plugin playlistPane],
[plugin updatesPane], [plugin hotKeyPane],
[plugin outputPane], [plugin updatesPane],
[plugin scrobblerPane], [plugin outputPane],
[plugin growlPane], [plugin scrobblerPane],
[plugin appearancePane], [plugin notificationsPane],
[plugin midiPane], [plugin appearancePane],
nil]; [plugin midiPane]];
} }
- (HotKeyPane *)hotKeyPane - (HotKeyPane *)hotKeyPane
{ {
return hotKeyPane; return hotKeyPane;
} }
- (OutputPane *)outputPane - (OutputPane *)outputPane
{ {
return outputPane; return outputPane;
} }
- (MIDIPane *)midiPane - (MIDIPane *)midiPane
@ -56,36 +56,51 @@
- (GeneralPreferencePane *)updatesPane - (GeneralPreferencePane *)updatesPane
{ {
return [GeneralPreferencePane preferencePaneWithView:updatesView title:NSLocalizedStringFromTableInBundle(@"Updates", nil, [NSBundle bundleForClass:[self class]], @"") iconNamed:@"updates"]; return [GeneralPreferencePane preferencePaneWithView:updatesView
title:NSLocalizedPrefString(@"Updates")
systemIconName:@"arrow.triangle.2.circlepath.circle.fill"
orOldIconNamed:@"updates"];
} }
- (GeneralPreferencePane *)scrobblerPane - (GeneralPreferencePane *)scrobblerPane
{ {
return [GeneralPreferencePane preferencePaneWithView:scrobblerView title:NSLocalizedStringFromTableInBundle(@"Last.fm", nil, [NSBundle bundleForClass:[self class]], @"") iconNamed:@"lastfm"]; return [GeneralPreferencePane preferencePaneWithView:scrobblerView
title:NSLocalizedPrefString(@"Scrobble")
systemIconName:@"dot.radiowaves.left.and.right"
orOldIconNamed:@"lastfm"];
} }
- (GeneralPreferencePane *)playlistPane - (GeneralPreferencePane *)playlistPane
{ {
return [GeneralPreferencePane preferencePaneWithView:playlistView title:NSLocalizedStringFromTableInBundle(@"Playlist", nil, [NSBundle bundleForClass:[self class]], @"") iconNamed:@"playlist"]; return [GeneralPreferencePane preferencePaneWithView:playlistView
title:NSLocalizedPrefString(@"Playlist")
systemIconName:@"music.note.list"
orOldIconNamed:@"playlist"];
} }
- (GeneralPreferencePane *)growlPane - (GeneralPreferencePane *)notificationsPane
{ {
if (@available(macOS 10.14, *)) { if (@available(macOS 10.14, *)) {
if (iTunesStyleCheck) { if (iTunesStyleCheck) {
iTunesStyleCheck.hidden = YES; iTunesStyleCheck.hidden = YES;
NSSize size = growlView.frame.size; NSSize size = notificationsView.frame.size;
size.height -= 18; size.height -= 18;
[growlView setFrameSize:size]; [notificationsView setFrameSize:size];
} }
} }
return [GeneralPreferencePane preferencePaneWithView:growlView title:NSLocalizedStringFromTableInBundle(@"Growl", nil, [NSBundle bundleForClass:[self class]], @"") iconNamed:@"growl"]; return [GeneralPreferencePane preferencePaneWithView:notificationsView
title:NSLocalizedPrefString(@"Notifications")
systemIconName:@"bell.fill"
orOldIconNamed:@"growl"];
} }
- (GeneralPreferencePane *)appearancePane - (GeneralPreferencePane *)appearancePane
{ {
return [GeneralPreferencePane preferencePaneWithView:appearanceView title:NSLocalizedStringFromTableInBundle(@"Appearance", nil, [NSBundle bundleForClass:[self class]], @"") iconNamed:@"appearance"]; return [GeneralPreferencePane preferencePaneWithView:appearanceView
title:NSLocalizedPrefString(@"Appearance")
systemIconName:@"paintpalette.fill"
orOldIconNamed:@"appearance"];
} }
@end @end

View File

@ -31,11 +31,13 @@ static void setControlText(HotKeyControl* control, NSString* kcprop, NSString* m
- (NSString *)title - (NSString *)title
{ {
return NSLocalizedStringFromTableInBundle(@"Hot Keys", nil, [NSBundle bundleForClass:[self class]], @""); return NSLocalizedPrefString(@"Hot Keys");
} }
- (NSImage *)icon - (NSImage *)icon
{ {
if (@available(macOS 11.0, *))
return [NSImage imageWithSystemSymbolName:@"keyboard" accessibilityDescription:nil];
return [[NSImage alloc] initWithContentsOfFile:[[NSBundle bundleForClass:[self class]] pathForImageResource:@"hot_keys"]]; return [[NSImage alloc] initWithContentsOfFile:[[NSBundle bundleForClass:[self class]] pathForImageResource:@"hot_keys"]];
} }

View File

@ -12,17 +12,19 @@
- (NSString *)title - (NSString *)title
{ {
return NSLocalizedStringFromTableInBundle(@"Synthesis", nil, [NSBundle bundleForClass:[self class]], @""); return NSLocalizedPrefString(@"Synthesis");
} }
- (NSImage *)icon - (NSImage *)icon
{ {
if (@available(macOS 11.0, *))
return [NSImage imageWithSystemSymbolName:@"pianokeys" accessibilityDescription:nil];
return [[NSImage alloc] initWithContentsOfFile:[[NSBundle bundleForClass:[self class]] pathForImageResource:@"midi"]]; return [[NSImage alloc] initWithContentsOfFile:[[NSBundle bundleForClass:[self class]] pathForImageResource:@"midi"]];
} }
- (IBAction)setSoundFont:(id)sender - (IBAction)setSoundFont:(id)sender
{ {
NSArray *fileTypes = [NSArray arrayWithObjects:@"sf2",@"sf2pack",@"sflist",@"json",nil]; NSArray *fileTypes = @[@"sf2", @"sf2pack", @"sflist", @"json"];
NSOpenPanel * panel = [NSOpenPanel openPanel]; NSOpenPanel * panel = [NSOpenPanel openPanel];
[panel setAllowsMultipleSelection:NO]; [panel setAllowsMultipleSelection:NO];
[panel setCanChooseDirectories:NO]; [panel setCanChooseDirectories:NO];
@ -42,10 +44,8 @@
- (IBAction)setMidiPlugin:(id)sender - (IBAction)setMidiPlugin:(id)sender
{ {
NSString * plugin = [[NSUserDefaults standardUserDefaults] stringForKey:@"midi.plugin"]; NSString * plugin = [[NSUserDefaults standardUserDefaults] stringForKey:@"midi.plugin"];
if ([plugin isEqualToString:@"Sc55rolD"] || [plugin isEqualToString:@"Sc55RoCl"]) BOOL enabled = [plugin isEqualToString:@"Sc55rolD"] || [plugin isEqualToString:@"Sc55RoCl"];
[midiFlavorControl setEnabled:YES]; [midiFlavorControl setEnabled:enabled];
else
[midiFlavorControl setEnabled:NO];
} }
@end @end

View File

@ -13,11 +13,13 @@
- (NSString *)title - (NSString *)title
{ {
return NSLocalizedStringFromTableInBundle(@"Output", nil, [NSBundle bundleForClass:[self class]], @""); return NSLocalizedPrefString(@"Output");
} }
- (NSImage *)icon - (NSImage *)icon
{ {
if (@available(macOS 11.0, *))
return [NSImage imageWithSystemSymbolName:@"hifispeaker.2.fill" accessibilityDescription:nil];
return [[NSImage alloc] initWithContentsOfFile:[[NSBundle bundleForClass:[self class]] pathForImageResource:@"output"]]; return [[NSImage alloc] initWithContentsOfFile:[[NSBundle bundleForClass:[self class]] pathForImageResource:@"output"]];
} }

View File

@ -8,20 +8,21 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#define NSLocalizedPrefString(key) \
[[NSBundle bundleWithIdentifier:@"org.cogx.cog.preferences"] localizedStringForKey:(key) value:@"" table:nil]
@protocol PreferencePane <NSObject>
@required
@property(readonly) NSView *view;
@property(readonly, copy) NSString *title;
@property(readonly) NSImage *icon;
@end
@protocol PreferencePanePlugin <NSObject> @protocol PreferencePanePlugin <NSObject>
@required @required
// An array of PrefPaneController instances that the plugin has available // An array of PrefPaneController instances that the plugin has available
+ (NSArray *)preferencePanes; + (NSArray<id<PreferencePane>> *)preferencePanes;
@end
@protocol PreferencePane <NSObject>
@required
- (NSView *)view;
- (NSString *)title;
- (NSImage *)icon;
@end @end

View File

@ -17,17 +17,13 @@
if (nil == window) { if (nil == window) {
// Determine path to the sample preference panes // Determine path to the sample preference panes
NSString *pluginPath = [[NSBundle mainBundle] pathForResource:@"General" ofType:@"preferencePane"]; NSString *pluginPath = [[NSBundle mainBundle] pathForResource:@"General" ofType:@"preferencePane"];
NSBundle *bundle = [NSBundle bundleWithPath:pluginPath]; NSBundle *bundle = [NSBundle bundleWithPath:pluginPath];
PreferencePluginController *pluginController = [[PreferencePluginController alloc] initWithPlugins:@[bundle]];
PreferencePluginController *pluginController = [[PreferencePluginController alloc] initWithPlugins:[NSArray arrayWithObject:bundle]];
window = [[PreferencesWindow alloc] initWithPreferencePanes:[pluginController preferencePanes]];
window = [[PreferencesWindow alloc] initWithPreferencePanes:[pluginController preferencePanes]];
// Set which panes are included, and their order.
//[prefs setPanesOrder:[NSArray arrayWithObjects:@"General", @"Updating", @"A Non-Existent Preference Pane", nil]];
} }
// Show the preferences window. // Show the preferences window.
[window show]; [window show];
} }

View File

@ -8,14 +8,18 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
/**
* TODO: Use NSTabViewController.
* This will allow to manage Toolbar automatically, lazy load
* preference panes and and crossfade between them.
*/
@interface PreferencesWindow : NSWindow<NSToolbarDelegate>
@interface PreferencesWindow : NSWindow<NSToolbarDelegate> { - (instancetype)initWithPreferencePanes:(NSArray *)preferencePanes NS_DESIGNATED_INITIALIZER;
NSMutableArray *preferencePaneOrder; - (instancetype)initWithContentRect:(NSRect)contentRect
NSMutableDictionary *preferencePanes; styleMask:(NSWindowStyleMask)style
NSMutableDictionary *toolbarItems; backing:(NSBackingStoreType)backingStoreType
} defer:(BOOL)flag NS_UNAVAILABLE;
- (id)initWithPreferencePanes:(NSArray *)preferencePanes;
- (void)show; - (void)show;

View File

@ -20,144 +20,148 @@
@end @end
@implementation PreferencesWindow @implementation PreferencesWindow {
NSMutableArray<NSToolbarItemIdentifier> *preferencePaneOrder;
NSMutableDictionary<NSToolbarItemIdentifier, id<PreferencePane>> *preferencePanes;
NSMutableDictionary<NSToolbarItemIdentifier, NSToolbarItem *> *toolbarItems;
}
- (id)initWithPreferencePanes:(NSArray *)panes - (instancetype)initWithPreferencePanes:(NSArray<id<PreferencePane>> *)panes
{ {
self = [super initWithContentRect:NSMakeRect(0, 0, 350, 200) NSWindowStyleMask windowStyleMask =
styleMask:(NSClosableWindowMask | NSResizableWindowMask | NSTitledWindowMask) (NSWindowStyleMaskClosable | NSWindowStyleMaskTitled);
backing:NSBackingStoreBuffered self = [super initWithContentRect:NSMakeRect(0, 0, 530, 300)
defer:NO]; styleMask:windowStyleMask
if (self) backing:NSBackingStoreBuffered
{ defer:NO];
preferencePaneOrder = [[NSMutableArray alloc] init]; if (self)
preferencePanes = [[NSMutableDictionary alloc] init]; {
preferencePaneOrder = [[NSMutableArray alloc] init];
for (id<PreferencePane> pane in panes) { preferencePanes = [[NSMutableDictionary alloc] init];
[preferencePaneOrder addObject:[pane title]];
[preferencePanes setObject:pane forKey:[pane title]]; for (id<PreferencePane> pane in panes) {
} [preferencePaneOrder addObject:[pane title]];
[preferencePanes setObject:pane forKey:[pane title]];
[self setReleasedWhenClosed:NO]; }
[self setTitle:@"Preferences"]; // initial default title
[self setShowsToolbarButton: NO]; [self setReleasedWhenClosed:NO];
[self setShowsResizeIndicator:NO]; [self setTitle:@"Preferences"];
[self center]; [self center];
[[self standardWindowButton:NSWindowZoomButton] setEnabled:FALSE];
if (@available(macOS 11, *)) { if (@available(macOS 11, *)) {
[self setToolbarStyle:NSWindowToolbarStylePreference]; [self setToolbarStyle:NSWindowToolbarStylePreference];
} }
[self createToolbar]; [self createToolbar];
} }
return self; return self;
} }
- (NSString *)lastPaneDefaultsKey - (NSString *)lastPaneDefaultsKey
{ {
return @"LastPreferencePane"; return @"LastPreferencePane";
}
-(NSRect)newFrameForNewContentView:(NSView *)view {
NSRect newFrame = [self frame];
newFrame.size.height = [view frame].size.height + ([self frame].size.height - [[self contentView] frame].size.height);
newFrame.size.width = [view frame].size.width;
newFrame.origin.y += ([[self contentView] frame].size.height - [view frame].size.height);
return newFrame;
} }
- (void)setContentView:(NSView *)view animate:(BOOL)animate - (void)setContentView:(NSView *)view animate:(BOOL)animate
{ {
NSSize newSize = view.bounds.size;
NSSize oldSize = [self contentView].bounds.size;
CGFloat diff = newSize.height - oldSize.height;
NSRect newFrame = [self frame];
newFrame.size.height += diff;
newFrame.origin.y -= diff;
if (animate) { if (animate) {
NSView *tempView = [[NSView alloc] initWithFrame:[[self contentView] frame]]; [self setContentView:nil];
[self setContentView:tempView];
} }
[self setFrame:newFrame display:animate animate:animate];
NSRect newFrame = [self newFrameForNewContentView:view];
[self setFrame:newFrame display:animate animate:animate]; [self setContentView:view];
[self setContentSize:newSize];
[self setContentView:view];
} }
- (BOOL)loadPaneNamed:(NSString *)name display:(BOOL)display - (BOOL)loadPaneNamed:(NSString *)name display:(BOOL)display
{ {
id<PreferencePane> paneController = [preferencePanes objectForKey:name]; id<PreferencePane> paneController = preferencePanes[name];
if (!paneController) { if (!paneController) {
return NO; return NO;
} }
NSView *paneView = [paneController view]; NSView *paneView = [paneController view];
if (!paneView) { if (!paneView || [self contentView] == paneView) {
return NO; return NO;
} }
[self setContentView:paneView animate:display]; [self setContentView:paneView animate:display];
[self setTitle:name];
// Update defaults // Update defaults
[[NSUserDefaults standardUserDefaults] setObject:name forKey:[self lastPaneDefaultsKey]]; [[NSUserDefaults standardUserDefaults] setObject:name forKey:[self lastPaneDefaultsKey]];
[[self toolbar] setSelectedItemIdentifier:name]; [[self toolbar] setSelectedItemIdentifier:name];
return YES; return YES;
} }
- (void)createToolbar - (void)createToolbar
{ {
toolbarItems = [[NSMutableDictionary alloc] init]; toolbarItems = [[NSMutableDictionary alloc] init];
for (NSString *name in preferencePaneOrder) { for (NSString *name in preferencePaneOrder) {
id<PreferencePane> pane = [preferencePanes objectForKey:name]; id<PreferencePane> pane = preferencePanes[name];
NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier:name]; NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier:name];
[item setPaletteLabel:name]; // item's label in the "Customize Toolbar" sheet (not relevant here, but we set it anyway) [item setPaletteLabel:name]; // item's label in the "Customize Toolbar" sheet (not relevant here, but we set it anyway)
[item setLabel:name]; // item's label in the toolbar [item setLabel:name]; // item's label in the toolbar
[item setToolTip:name]; [item setToolTip:name];
[item setImage:[pane icon]]; [item setImage:[pane icon]];
[item setTarget:self]; [item setTarget:self];
[item setAction:@selector(toolbarItemClicked:)]; // action called when item is clicked [item setAction:@selector(toolbarItemClicked:)]; // action called when item is clicked
[toolbarItems setObject:item forKey:name]; toolbarItems[name] = item;
} }
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier]; NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier:[bundleIdentifier stringByAppendingString:@" Preferences Toolbar"]]; NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier:[bundleIdentifier stringByAppendingString:@" Preferences Toolbar"]];
[toolbar setDelegate:self]; [toolbar setDelegate:self];
[toolbar setAllowsUserCustomization:NO]; [toolbar setAllowsUserCustomization:NO];
[toolbar setAutosavesConfiguration:NO]; [toolbar setAutosavesConfiguration:NO];
[toolbar setDisplayMode:NSToolbarDisplayModeIconAndLabel]; [toolbar setDisplayMode:NSToolbarDisplayModeIconAndLabel];
[toolbar setSizeMode:NSToolbarSizeModeDefault]; [toolbar setSizeMode:NSToolbarSizeModeDefault];
[self setToolbar:toolbar]; [self setToolbar:toolbar];
} }
- (void)show - (void)show
{ {
NSString *lastPane = [[NSUserDefaults standardUserDefaults] objectForKey:[self lastPaneDefaultsKey]]; NSString *lastPane = [[NSUserDefaults standardUserDefaults] objectForKey:[self lastPaneDefaultsKey]];
if (nil == lastPane) { // Previous pane names migrations.
if (0 >= [preferencePaneOrder count]) { if ([lastPane isEqualToString:NSLocalizedPrefString(@"Growl")]) {
ALog(@"Error: Preference panes not found!"); lastPane = NSLocalizedPrefString(@"Notifications");
} }
if ([lastPane isEqualToString:NSLocalizedPrefString(@"Last.fm")]) {
lastPane = [preferencePaneOrder objectAtIndex:0]; lastPane = NSLocalizedPrefString(@"Scrobble");
} }
if (nil == lastPane) {
[self loadPaneNamed:lastPane display:NO]; if (0 >= [preferencePaneOrder count]) {
ALog(@"Error: Preference panes not found!");
[self makeKeyAndOrderFront:self]; }
lastPane = preferencePaneOrder[0];
}
[self loadPaneNamed:lastPane display:NO];
[self makeKeyAndOrderFront:self];
} }
// Close on Esc pressed.
- (void)cancelOperation:(id)sender {
[self close];
}
#pragma mark Delegate methods #pragma mark Delegate methods
@ -180,14 +184,12 @@
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
{ {
return [toolbarItems objectForKey:itemIdentifier]; return toolbarItems[itemIdentifier];
} }
- (void)toolbarItemClicked:(NSToolbarItem *)item - (void)toolbarItemClicked:(NSToolbarItem *)item
{ {
if (![[item itemIdentifier] isEqualToString:[self title]]) { [self loadPaneNamed:[item itemIdentifier] display:YES];
[self loadPaneNamed:[item itemIdentifier] display:YES];
}
} }
@end @end