1
1
mirror of https://github.com/danbee/persephone synced 2025-03-04 08:39:11 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
9e5e0e38e5
Add up to date screenshot 2019-02-11 08:30:18 -05:00
27bea644d6
Refactor a bunch of things 2019-02-11 08:30:08 -05:00
7 changed files with 36 additions and 31 deletions

View File

@ -46,8 +46,7 @@ class AlbumViewController: NSViewController,
guard let albumItem = item as? AlbumItem else { return item } guard let albumItem = item as? AlbumItem else { return item }
albumItem.view.wantsLayer = true albumItem.view.wantsLayer = true
albumItem.setAlbumTitle(albums[indexPath.item].title) albumItem.setAlbum(albums[indexPath.item])
albumItem.setAlbumArtist(albums[indexPath.item].artist)
return albumItem return albumItem
} }

View File

@ -182,19 +182,18 @@ class MPDClient {
mpd_search_add_group_tag(self.connection, MPD_TAG_ALBUM_ARTIST) mpd_search_add_group_tag(self.connection, MPD_TAG_ALBUM_ARTIST)
mpd_search_commit(self.connection) mpd_search_commit(self.connection)
while let mpdPair = mpd_recv_pair(self.connection) { while let mpdPair = mpd_recv_pair(self.connection) {
let name = String(cString: mpdPair.pointee.name) let pair = Pair(mpdPair)
let value = String(cString: mpdPair.pointee.value)
switch name { switch pair.name {
case "AlbumArtist": case "AlbumArtist":
artist = value artist = pair.value
case "Album": case "Album":
albums.append(Album(title: value, artist: artist)) albums.append(Album(title: pair.value, artist: artist))
default: default:
break break
} }
mpd_return_pair(self.connection, mpdPair) mpd_return_pair(self.connection, pair.mpdPair)
} }
delegate?.didLoadAlbums(mpdClient: self, albums: albums) delegate?.didLoadAlbums(mpdClient: self, albums: albums)

View File

@ -15,4 +15,12 @@ class Pair {
init(_ mpdPair: UnsafeMutablePointer<mpd_pair>) { init(_ mpdPair: UnsafeMutablePointer<mpd_pair>) {
self.mpdPair = mpdPair self.mpdPair = mpdPair
} }
var name: String {
get { return String(cString: mpdPair.pointee.name) }
}
var value: String {
get { return String(cString: mpdPair.pointee.value) }
}
} }

View File

@ -14,12 +14,9 @@ class AlbumItem: NSCollectionViewItem {
// Do view setup here. // Do view setup here.
} }
func setAlbumTitle(_ title: String) { func setAlbum(_ album: MPDClient.Album) {
albumTitle.stringValue = title albumTitle.stringValue = album.title
} albumArtist.stringValue = album.artist
func setAlbumArtist(_ artist: String) {
albumArtist.stringValue = artist
} }
@IBOutlet var albumTitle: NSTextField! @IBOutlet var albumTitle: NSTextField!

View File

@ -16,41 +16,43 @@
<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="Hz6-mo-xeY"> <customView id="Hz6-mo-xeY">
<rect key="frame" x="0.0" y="0.0" width="206" height="248"/> <rect key="frame" x="0.0" y="0.0" width="160" height="207"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews> <subviews>
<textField identifier="albumTitle" horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" preferredMaxLayoutWidth="206" translatesAutoresizingMaskIntoConstraints="NO" id="KEh-NL-c2W"> <imageView identifier="albumArtwork" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Kfb-8f-ean">
<rect key="frame" x="-2" y="20" width="210" height="17"/> <rect key="frame" x="0.0" y="45" width="160" height="162"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="blankAlbum" id="FsA-JX-BFh"/>
</imageView>
<textField identifier="albumTitle" horizontalHuggingPriority="251" verticalHuggingPriority="750" preferredMaxLayoutWidth="206" translatesAutoresizingMaskIntoConstraints="NO" id="KEh-NL-c2W">
<rect key="frame" x="-2" y="20" width="164" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" title="Label" id="pDs-0t-e1j"> <textFieldCell key="cell" lineBreakMode="truncatingTail" title="Label" id="pDs-0t-e1j">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
</textField> </textField>
<textField identifier="albumArtist" horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" preferredMaxLayoutWidth="206" translatesAutoresizingMaskIntoConstraints="NO" id="5Uu-j1-qyT"> <textField identifier="albumArtist" horizontalHuggingPriority="251" verticalHuggingPriority="750" preferredMaxLayoutWidth="206" translatesAutoresizingMaskIntoConstraints="NO" id="5Uu-j1-qyT">
<rect key="frame" x="-2" y="0.0" width="210" height="17"/> <rect key="frame" x="-2" y="0.0" width="164" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" title="Label" id="yZn-e9-zyP"> <textFieldCell key="cell" lineBreakMode="truncatingTail" title="Label" id="yZn-e9-zyP">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
</textField> </textField>
<imageView identifier="albumArtwork" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Kfb-8f-ean">
<rect key="frame" x="0.0" y="42" width="206" height="206"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="blankAlbum" id="FsA-JX-BFh"/>
</imageView>
</subviews> </subviews>
<constraints> <constraints>
<constraint firstItem="KEh-NL-c2W" firstAttribute="leading" secondItem="5Uu-j1-qyT" secondAttribute="leading" id="Iji-NN-ju3"/> <constraint firstItem="5Uu-j1-qyT" firstAttribute="trailing" secondItem="KEh-NL-c2W" secondAttribute="trailing" id="64z-uz-4nY"/>
<constraint firstAttribute="bottom" secondItem="KEh-NL-c2W" secondAttribute="bottom" constant="20" symbolic="YES" id="8Kg-1r-wNp"/>
<constraint firstItem="Kfb-8f-ean" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="JMi-4i-dgs"/> <constraint firstItem="Kfb-8f-ean" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="JMi-4i-dgs"/>
<constraint firstItem="KEh-NL-c2W" firstAttribute="top" secondItem="Kfb-8f-ean" secondAttribute="bottom" constant="5" id="Jdb-sY-lnB"/>
<constraint firstAttribute="trailing" secondItem="Kfb-8f-ean" secondAttribute="trailing" id="KQC-Wz-Bsg"/> <constraint firstAttribute="trailing" secondItem="Kfb-8f-ean" secondAttribute="trailing" id="KQC-Wz-Bsg"/>
<constraint firstItem="5Uu-j1-qyT" firstAttribute="leading" secondItem="KEh-NL-c2W" secondAttribute="leading" id="MUo-0i-fX9"/>
<constraint firstItem="Kfb-8f-ean" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="Qbk-jx-zAi"/> <constraint firstItem="Kfb-8f-ean" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="Qbk-jx-zAi"/>
<constraint firstItem="Kfb-8f-ean" firstAttribute="leading" secondItem="KEh-NL-c2W" secondAttribute="leading" id="diY-bi-0Yg"/> <constraint firstItem="KEh-NL-c2W" firstAttribute="trailing" secondItem="Kfb-8f-ean" secondAttribute="trailing" id="U0w-G4-ggX"/>
<constraint firstAttribute="bottom" secondItem="5Uu-j1-qyT" secondAttribute="bottom" id="puG-ym-5hh"/> <constraint firstItem="KEh-NL-c2W" firstAttribute="leading" secondItem="Kfb-8f-ean" secondAttribute="leading" id="V8r-Rc-Dx7"/>
<constraint firstAttribute="bottom" secondItem="KEh-NL-c2W" secondAttribute="bottom" constant="20" symbolic="YES" id="yIJ-L1-2c5"/> <constraint firstItem="KEh-NL-c2W" firstAttribute="top" secondItem="Kfb-8f-ean" secondAttribute="bottom" constant="8" symbolic="YES" id="XFx-sv-dpF"/>
<constraint firstAttribute="bottom" secondItem="5Uu-j1-qyT" secondAttribute="bottom" id="gci-4h-pDZ"/>
</constraints> </constraints>
<point key="canvasLocation" x="3" y="142"/> <point key="canvasLocation" x="-22" y="139.5"/>
</customView> </customView>
<collectionViewItem id="Qgu-aI-55A" customClass="AlbumItem" customModule="Persephone" customModuleProvider="target"/> <collectionViewItem id="Qgu-aI-55A" customClass="AlbumItem" customModule="Persephone" customModuleProvider="target"/>
</objects> </objects>

View File

@ -926,7 +926,7 @@
<rect key="frame" x="0.0" y="0.0" width="450" height="158"/> <rect key="frame" x="0.0" y="0.0" width="450" height="158"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumInteritemSpacing="20" minimumLineSpacing="20" id="K0l-P8-OW0"> <collectionViewFlowLayout key="collectionViewLayout" minimumInteritemSpacing="20" minimumLineSpacing="20" id="K0l-P8-OW0">
<size key="itemSize" width="206" height="248"/> <size key="itemSize" width="159" height="207"/>
<edgeInsets key="sectionInset" left="40" right="40" top="20" bottom="60"/> <edgeInsets key="sectionInset" left="40" right="40" top="20" bottom="60"/>
</collectionViewFlowLayout> </collectionViewFlowLayout>
<color key="primaryBackgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="primaryBackgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 172 KiB