[vlc-commits] macosx/media source: switch to a collection view with a custom cell for representation

Felix Paul Kühne git at videolan.org
Mon Apr 29 19:26:55 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Wed Apr 24 19:18:35 2019 +0200| [fbad22a6049612761c500ff9bcbef02f57c724f2] | committer: Felix Paul Kühne

macosx/media source: switch to a collection view with a custom cell for representation

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fbad22a6049612761c500ff9bcbef02f57c724f2
---

 .../package/macosx/VLC.xcodeproj/project.pbxproj   |   8 ++
 modules/gui/macosx/Makefile.am                     |   3 +
 modules/gui/macosx/UI/VLCLibraryWindow.xib         |  76 ++++---------
 .../macosx/UI/VLCMediaSourceCollectionViewItem.xib |  45 ++++++++
 modules/gui/macosx/library/VLCLibraryModel.h       |   1 -
 modules/gui/macosx/library/VLCLibraryWindow.h      |   2 +-
 modules/gui/macosx/library/VLCLibraryWindow.m      |  15 +--
 modules/gui/macosx/media-source/VLCMediaSource.m   |   3 +
 .../VLCMediaSourceCollectionViewItem.h             |  38 +++++++
 .../VLCMediaSourceCollectionViewItem.m             |  40 +++++++
 .../macosx/media-source/VLCMediaSourceDataSource.h |   9 +-
 .../macosx/media-source/VLCMediaSourceDataSource.m | 118 +++++++--------------
 po/POTFILES.in                                     |   2 +
 13 files changed, 218 insertions(+), 142 deletions(-)

diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
index 7aac5fe4a8..98fc938254 100644
--- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj
+++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
@@ -148,6 +148,7 @@
 		7DC21A7422049A6600F98A02 /* VLCOpenInputMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DC21A7322049A6600F98A02 /* VLCOpenInputMetadata.m */; };
 		7DD2F5C52081B73B007EE187 /* VLCRemoteControlService.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DD2F5C42081B73B007EE187 /* VLCRemoteControlService.m */; };
 		7DE9C7DD220728420089108F /* VLCPlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DE9C7DC220728420089108F /* VLCPlayerController.m */; };
+		7DF14FBD2270CB1C0008ABE4 /* VLCMediaSourceCollectionViewItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DF14FBB2270CB1C0008ABE4 /* VLCMediaSourceCollectionViewItem.m */; };
 		7DFBDCA82269E77500B700A5 /* VLCLibraryController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DFBDCA72269E77500B700A5 /* VLCLibraryController.m */; };
 		7DFBDCAB2269E77F00B700A5 /* VLCLibraryModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DFBDCAA2269E77F00B700A5 /* VLCLibraryModel.m */; };
 		7DFBDCAE2269ED0C00B700A5 /* VLCLibraryDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DFBDCAD2269ED0C00B700A5 /* VLCLibraryDataSource.m */; };
@@ -509,6 +510,9 @@
 		7DE9C7DC220728420089108F /* VLCPlayerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCPlayerController.m; sourceTree = "<group>"; };
 		7DF0435E1972E26A0022B534 /* VLCAddonListItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCAddonListItem.h; sourceTree = "<group>"; };
 		7DF0435F1972E26A0022B534 /* VLCAddonListItem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCAddonListItem.m; sourceTree = "<group>"; };
+		7DF14FBA2270CB1C0008ABE4 /* VLCMediaSourceCollectionViewItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCMediaSourceCollectionViewItem.h; sourceTree = "<group>"; };
+		7DF14FBB2270CB1C0008ABE4 /* VLCMediaSourceCollectionViewItem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCMediaSourceCollectionViewItem.m; sourceTree = "<group>"; };
+		7DF14FBC2270CB1C0008ABE4 /* VLCMediaSourceCollectionViewItem.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = VLCMediaSourceCollectionViewItem.xib; sourceTree = "<group>"; };
 		7DF812ED1B555A340052293C /* VLCPlaybackContinuityController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCPlaybackContinuityController.h; sourceTree = "<group>"; };
 		7DF812EE1B555A340052293C /* VLCPlaybackContinuityController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCPlaybackContinuityController.m; sourceTree = "<group>"; };
 		7DF812EF1B555C8E0052293C /* VLCKeyboardBacklightControl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCKeyboardBacklightControl.h; sourceTree = "<group>"; };
@@ -1323,6 +1327,8 @@
 				7DFBDCBD226CED7200B700A5 /* VLCMediaSource.m */,
 				7DFBDCC2226E445500B700A5 /* VLCMediaSourceDataSource.h */,
 				7DFBDCC3226E445500B700A5 /* VLCMediaSourceDataSource.m */,
+				7DF14FBA2270CB1C0008ABE4 /* VLCMediaSourceCollectionViewItem.h */,
+				7DF14FBB2270CB1C0008ABE4 /* VLCMediaSourceCollectionViewItem.m */,
 			);
 			path = "media-source";
 			sourceTree = "<group>";
@@ -1432,6 +1438,7 @@
 				7D0F64002201F66D00FDB91F /* VLCPlaylistTableCellView.xib */,
 				7D445D8F220339D400263D34 /* VLCPlaylistMenu.xib */,
 				7D0F64052202047900FDB91F /* VLCLibraryCollectionViewItem.xib */,
+				7DF14FBC2270CB1C0008ABE4 /* VLCMediaSourceCollectionViewItem.xib */,
 				6B82241A1E4D2A9000833BE1 /* VLCStatusBarIconMainMenu.xib */,
 				6B8224181E4D2A9000833BE1 /* VLCFullScreenPanel.xib */,
 				6B8223FE1E4D2A8F00833BE1 /* About.xib */,
@@ -1633,6 +1640,7 @@
 				1C3113C71E508C6900D4DD76 /* VLCOpenWindowController.m in Sources */,
 				7D0F64062202047900FDB91F /* VLCLibraryCollectionViewItem.m in Sources */,
 				7D713D322201AE350042BEB7 /* VLCLibraryWindow.m in Sources */,
+				7DF14FBD2270CB1C0008ABE4 /* VLCMediaSourceCollectionViewItem.m in Sources */,
 				1C3113C91E508C6900D4DD76 /* VLCOutput.m in Sources */,
 				1C1C62011F8260A90052DD4F /* VLCWrappableTextField.m in Sources */,
 				6BBB05DA1EEFEA29003A1019 /* VLCHUDOutlineView.m in Sources */,
diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am
index 5eca280481..78ac1c9233 100644
--- a/modules/gui/macosx/Makefile.am
+++ b/modules/gui/macosx/Makefile.am
@@ -71,6 +71,8 @@ libmacosx_plugin_la_SOURCES = \
 	gui/macosx/main/macosx.m \
 	gui/macosx/media-source/VLCMediaSource.h \
 	gui/macosx/media-source/VLCMediaSource.m \
+	gui/macosx/media-source/VLCMediaSourceCollectionViewItem.h \
+	gui/macosx/media-source/VLCMediaSourceCollectionViewItem.m \
 	gui/macosx/media-source/VLCMediaSourceDataSource.h \
 	gui/macosx/media-source/VLCMediaSourceDataSource.m \
 	gui/macosx/media-source/VLCMediaSourceProvider.h \
@@ -241,6 +243,7 @@ libmacosx_plugin_la_XIB_SOURCES = \
 	gui/macosx/UI/VLCPlaylistMenu.xib \
 	gui/macosx/UI/VLCPlaylistTableCellView.xib \
 	gui/macosx/UI/VLCLibraryCollectionViewItem.xib \
+	gui/macosx/UI/VLCMediaSourceCollectionViewItem.xib \
 	gui/macosx/UI/MediaInfo.xib \
 	gui/macosx/UI/Open.xib \
 	gui/macosx/UI/PlaylistAccessoryView.xib \
diff --git a/modules/gui/macosx/UI/VLCLibraryWindow.xib b/modules/gui/macosx/UI/VLCLibraryWindow.xib
index 4308834f0f..857e20fc7e 100644
--- a/modules/gui/macosx/UI/VLCLibraryWindow.xib
+++ b/modules/gui/macosx/UI/VLCLibraryWindow.xib
@@ -69,75 +69,41 @@
                                             <autoresizingMask key="autoresizingMask"/>
                                         </scroller>
                                     </scrollView>
-                                    <scrollView borderType="groove" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="StN-Jd-vFI">
+                                    <scrollView wantsLayer="YES" borderType="none" autohidesScrollers="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cFG-c9-cI9">
                                         <rect key="frame" x="0.0" y="0.0" width="242" height="291"/>
-                                        <clipView key="contentView" id="bCd-C3-hHf">
-                                            <rect key="frame" x="2" y="2" width="238" height="287"/>
+                                        <clipView key="contentView" id="tI4-x3-55j">
+                                            <rect key="frame" x="0.0" y="0.0" width="242" height="291"/>
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                             <subviews>
-                                                <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="jpB-GR-lUa">
-                                                    <rect key="frame" x="0.0" y="0.0" width="238" height="287"/>
-                                                    <autoresizingMask key="autoresizingMask"/>
-                                                    <size key="intercellSpacing" width="3" height="2"/>
-                                                    <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                    <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
-                                                    <tableColumns>
-                                                        <tableColumn width="235" minWidth="40" maxWidth="1000" id="J5a-b7-jfY">
-                                                            <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
-                                                                <font key="font" metaFont="smallSystem"/>
-                                                                <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
-                                                                <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
-                                                            </tableHeaderCell>
-                                                            <textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="ecA-vR-33j">
-                                                                <font key="font" metaFont="system"/>
-                                                                <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
-                                                                <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                            </textFieldCell>
-                                                            <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
-                                                            <prototypeCellViews>
-                                                                <tableCellView id="SJC-NO-4mY">
-                                                                    <rect key="frame" x="1" y="1" width="235" height="17"/>
-                                                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                                                    <subviews>
-                                                                        <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xoJ-y7-ayy">
-                                                                            <rect key="frame" x="0.0" y="0.0" width="235" height="17"/>
-                                                                            <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
-                                                                            <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="qc9-Zy-xBC">
-                                                                                <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>
-                                                                    </subviews>
-                                                                    <connections>
-                                                                        <outlet property="textField" destination="xoJ-y7-ayy" id="Vbb-iK-ddd"/>
-                                                                    </connections>
-                                                                </tableCellView>
-                                                            </prototypeCellViews>
-                                                        </tableColumn>
-                                                    </tableColumns>
-                                                </tableView>
+                                                <collectionView id="r7v-GI-W1U">
+                                                    <rect key="frame" x="0.0" y="0.0" width="242" height="158"/>
+                                                    <autoresizingMask key="autoresizingMask" widthSizable="YES"/>
+                                                    <collectionViewFlowLayout key="collectionViewLayout" minimumInteritemSpacing="10" minimumLineSpacing="10" id="v0C-1b-7Ss">
+                                                        <size key="itemSize" width="210" height="150"/>
+                                                    </collectionViewFlowLayout>
+                                                    <color key="primaryBackgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                                </collectionView>
                                             </subviews>
                                         </clipView>
-                                        <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="iwL-84-2YW">
-                                            <rect key="frame" x="2" y="117" width="236" height="16"/>
+                                        <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="WUt-1y-tQd">
+                                            <rect key="frame" x="1" y="143" width="240" height="16"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                         </scroller>
-                                        <scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="H17-SV-gee">
-                                            <rect key="frame" x="224" y="17" width="15" height="102"/>
+                                        <scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="247-FY-ZXk">
+                                            <rect key="frame" x="234" y="1" width="15" height="143"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                         </scroller>
                                     </scrollView>
                                 </subviews>
                                 <constraints>
-                                    <constraint firstAttribute="bottom" secondItem="StN-Jd-vFI" secondAttribute="bottom" id="EVe-lP-xOg"/>
+                                    <constraint firstAttribute="trailing" secondItem="cFG-c9-cI9" secondAttribute="trailing" id="0zl-H8-IAo"/>
+                                    <constraint firstItem="cFG-c9-cI9" firstAttribute="leading" secondItem="iSp-bV-w6B" secondAttribute="leading" id="8SS-VG-YAQ"/>
                                     <constraint firstItem="nXS-11-7iK" firstAttribute="leading" secondItem="iSp-bV-w6B" secondAttribute="leading" id="SPv-yC-58y"/>
                                     <constraint firstItem="nXS-11-7iK" firstAttribute="top" secondItem="iSp-bV-w6B" secondAttribute="top" id="Sje-VZ-Kcw"/>
                                     <constraint firstAttribute="trailing" secondItem="nXS-11-7iK" secondAttribute="trailing" id="Tuh-vj-qaU"/>
-                                    <constraint firstAttribute="trailing" secondItem="StN-Jd-vFI" secondAttribute="trailing" id="aBt-Lo-Cvu"/>
-                                    <constraint firstItem="StN-Jd-vFI" firstAttribute="leading" secondItem="iSp-bV-w6B" secondAttribute="leading" id="bGP-Wn-WoI"/>
+                                    <constraint firstAttribute="bottom" secondItem="cFG-c9-cI9" secondAttribute="bottom" id="oAJ-yE-oGZ"/>
                                     <constraint firstAttribute="bottom" secondItem="nXS-11-7iK" secondAttribute="bottom" id="piy-A4-FaO"/>
-                                    <constraint firstItem="StN-Jd-vFI" firstAttribute="top" secondItem="iSp-bV-w6B" secondAttribute="top" id="y5h-3Q-xb5"/>
+                                    <constraint firstItem="cFG-c9-cI9" firstAttribute="top" secondItem="iSp-bV-w6B" secondAttribute="top" id="wBq-BN-AMy"/>
                                 </constraints>
                             </customView>
                             <customView id="dus-WQ-AmE">
@@ -359,8 +325,8 @@
             </view>
             <connections>
                 <outlet property="libraryCollectionView" destination="B8x-e8-7zp" id="djF-Lw-nXT"/>
-                <outlet property="mediaSourceScrollView" destination="StN-Jd-vFI" id="i2e-GX-VfP"/>
-                <outlet property="mediaSourceTableView" destination="jpB-GR-lUa" id="NQ0-0c-wdU"/>
+                <outlet property="mediaSourceCollectionView" destination="r7v-GI-W1U" id="3JJ-GU-o5o"/>
+                <outlet property="mediaSourceScrollView" destination="cFG-c9-cI9" id="gRO-Y7-kdb"/>
                 <outlet property="playlistTableView" destination="Fr1-af-8gb" id="yaB-Ab-jrx"/>
                 <outlet property="segmentedTitleControl" destination="W1M-0o-qYG" id="Gw1-T6-78k"/>
                 <outlet property="videoView" destination="12s-0J-Uvj" id="zTg-s0-qZ5"/>
diff --git a/modules/gui/macosx/UI/VLCMediaSourceCollectionViewItem.xib b/modules/gui/macosx/UI/VLCMediaSourceCollectionViewItem.xib
new file mode 100644
index 0000000000..d7dfe13eb4
--- /dev/null
+++ b/modules/gui/macosx/UI/VLCMediaSourceCollectionViewItem.xib
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+    <dependencies>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner" customClass="VLCMediaSourceCollectionViewItem">
+            <connections>
+                <outlet property="mediaImageView" destination="rko-Nc-j4c" id="4SM-TL-qbd"/>
+                <outlet property="titleTextField" destination="jJ3-BQ-y8F" id="YO5-1X-TIk"/>
+                <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
+            </connections>
+        </customObject>
+        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+        <customView id="Hz6-mo-xeY">
+            <rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
+            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+            <subviews>
+                <customView translatesAutoresizingMaskIntoConstraints="NO" id="rko-Nc-j4c" customClass="VLCImageView">
+                    <rect key="frame" x="198" y="178" width="84" height="84"/>
+                    <constraints>
+                        <constraint firstAttribute="width" secondItem="rko-Nc-j4c" secondAttribute="height" multiplier="1:1" id="tGe-gB-9im"/>
+                        <constraint firstAttribute="width" constant="84" id="wkF-ab-s15"/>
+                    </constraints>
+                </customView>
+                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jJ3-BQ-y8F">
+                    <rect key="frame" x="223" y="150" width="35" height="16"/>
+                    <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="Utm-F6-CKx">
+                        <font key="font" metaFont="controlContent"/>
+                        <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                    </textFieldCell>
+                </textField>
+            </subviews>
+            <constraints>
+                <constraint firstItem="jJ3-BQ-y8F" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="6rw-Fo-fZJ"/>
+                <constraint firstItem="jJ3-BQ-y8F" firstAttribute="top" secondItem="rko-Nc-j4c" secondAttribute="bottom" constant="12" id="86t-IA-OYg"/>
+                <constraint firstItem="rko-Nc-j4c" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="10" id="Va8-hk-LhR"/>
+                <constraint firstItem="rko-Nc-j4c" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="y9r-R9-030"/>
+            </constraints>
+        </customView>
+    </objects>
+</document>
diff --git a/modules/gui/macosx/library/VLCLibraryModel.h b/modules/gui/macosx/library/VLCLibraryModel.h
index 4dd09c8603..555147a578 100644
--- a/modules/gui/macosx/library/VLCLibraryModel.h
+++ b/modules/gui/macosx/library/VLCLibraryModel.h
@@ -29,7 +29,6 @@ NS_ASSUME_NONNULL_BEGIN
 typedef NS_ENUM(NSInteger, VLCLibraryMode) {
     VLCLibraryModeAudio,
     VLCLibraryModeVideo,
-    VLCLibraryModeNetwork,
 };
 
 @class VLCMediaLibraryMediaItem;
diff --git a/modules/gui/macosx/library/VLCLibraryWindow.h b/modules/gui/macosx/library/VLCLibraryWindow.h
index 2f17befa2a..26e2766ec0 100644
--- a/modules/gui/macosx/library/VLCLibraryWindow.h
+++ b/modules/gui/macosx/library/VLCLibraryWindow.h
@@ -37,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 @property (readwrite, weak) IBOutlet NSSegmentedControl *segmentedTitleControl;
 @property (readwrite, weak) IBOutlet VLCLibraryCollectionView *libraryCollectionView;
- at property (readwrite, weak) IBOutlet NSTableView *mediaSourceTableView;
+ at property (readwrite, weak) IBOutlet NSCollectionView *mediaSourceCollectionView;
 @property (readwrite, weak) IBOutlet NSScrollView *mediaSourceScrollView;
 @property (readwrite, weak) IBOutlet NSTableView *playlistTableView;
 
diff --git a/modules/gui/macosx/library/VLCLibraryWindow.m b/modules/gui/macosx/library/VLCLibraryWindow.m
index 97a86c63a5..a6c5b96ced 100644
--- a/modules/gui/macosx/library/VLCLibraryWindow.m
+++ b/modules/gui/macosx/library/VLCLibraryWindow.m
@@ -34,6 +34,7 @@
 #import "library/VLCLibraryModel.h"
 #import "library/VLCLibraryMenuController.h"
 
+#import "media-source/VLCMediaSourceCollectionViewItem.h"
 #import "media-source/VLCMediaSourceDataSource.h"
 
 #import "windows/mainwindow/VLCControlsBarCommon.h"
@@ -77,12 +78,13 @@ static const float f_playlist_row_height = 72.;
     _fspanel = [[VLCFSPanelController alloc] init];
     [_fspanel showWindow:self];
 
-    _segmentedTitleControl.segmentCount = 3;
+    _segmentedTitleControl.segmentCount = 4;
     [_segmentedTitleControl setTarget:self];
     [_segmentedTitleControl setAction:@selector(segmentedControlAction:)];
     [_segmentedTitleControl setLabel:_NS("Music") forSegment:0];
     [_segmentedTitleControl setLabel:_NS("Video") forSegment:1];
-    [_segmentedTitleControl setLabel:_NS("Network") forSegment:2];
+    [_segmentedTitleControl setLabel:_NS("Local Network") forSegment:2];
+    [_segmentedTitleControl setLabel:_NS("Internet") forSegment:3];
     [_segmentedTitleControl sizeToFit];
 
     VLCMain *mainInstance = [VLCMain sharedInstance];
@@ -105,9 +107,9 @@ static const float f_playlist_row_height = 72.;
     [_libraryCollectionView registerClass:[VLCLibraryCollectionViewItem class] forItemWithIdentifier:VLCLibraryCellIdentifier];
 
     _mediaSourceDataSource = [[VLCMediaSourceDataSource alloc] init];
-    _mediaSourceTableView.dataSource = _mediaSourceDataSource;
-    _mediaSourceTableView.delegate = _mediaSourceDataSource;
-    _mediaSourceTableView.rowHeight = f_playlist_row_height;
+    _mediaSourceCollectionView.dataSource = _mediaSourceDataSource;
+    _mediaSourceCollectionView.delegate = _mediaSourceDataSource;
+    [_mediaSourceCollectionView registerClass:[VLCMediaSourceCollectionViewItem class] forItemWithIdentifier:VLCMediaSourceCellIdentifier];
 
     [self segmentedControlAction:nil];
 }
@@ -135,10 +137,9 @@ static const float f_playlist_row_height = 72.;
             break;
 
         default:
-            _libraryDataSource.libraryModel.libraryMode = VLCLibraryModeNetwork;
             _mediaSourceScrollView.hidden = NO;
             _libraryCollectionView.hidden = YES;
-            [_mediaSourceTableView reloadData];
+            [_mediaSourceCollectionView reloadData];
             break;
     }
 }
diff --git a/modules/gui/macosx/media-source/VLCMediaSource.m b/modules/gui/macosx/media-source/VLCMediaSource.m
index a7a1615465..7e09931002 100644
--- a/modules/gui/macosx/media-source/VLCMediaSource.m
+++ b/modules/gui/macosx/media-source/VLCMediaSource.m
@@ -108,6 +108,9 @@ static const struct vlc_media_tree_callbacks treeCallbacks = {
 
 - (void)preparseInputItemWithinTree:(VLCInputItem *)inputItem
 {
+    if (inputItem == nil) {
+        return;
+    }
     vlc_media_tree_Preparse(_p_mediaSource->tree, _p_libvlcInstance, inputItem.vlcInputItem);
 }
 
diff --git a/modules/gui/macosx/media-source/VLCMediaSourceCollectionViewItem.h b/modules/gui/macosx/media-source/VLCMediaSourceCollectionViewItem.h
new file mode 100644
index 0000000000..0ff4251712
--- /dev/null
+++ b/modules/gui/macosx/media-source/VLCMediaSourceCollectionViewItem.h
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * VLCMediaSourceCollectionViewItem.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2019 VLC authors and VideoLAN
+ *
+ * Authors: Felix Paul Kühne <fkuehne # videolan -dot- org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+ at class VLCImageView;
+
+extern NSString *VLCMediaSourceCellIdentifier;
+
+ at interface VLCMediaSourceCollectionViewItem : NSCollectionViewItem
+
+ at property (readwrite, assign) IBOutlet NSTextField *titleTextField;
+ at property (readwrite, assign) IBOutlet VLCImageView *mediaImageView;
+
+ at end
+
+NS_ASSUME_NONNULL_END
diff --git a/modules/gui/macosx/media-source/VLCMediaSourceCollectionViewItem.m b/modules/gui/macosx/media-source/VLCMediaSourceCollectionViewItem.m
new file mode 100644
index 0000000000..29b7b9b71a
--- /dev/null
+++ b/modules/gui/macosx/media-source/VLCMediaSourceCollectionViewItem.m
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * VLCMediaSourceCollectionViewItem.m: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2019 VLC authors and VideoLAN
+ *
+ * Authors: Felix Paul Kühne <fkuehne # videolan -dot- org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import "VLCMediaSourceCollectionViewItem.h"
+#import "views/VLCImageView.h"
+
+NSString *VLCMediaSourceCellIdentifier = @"VLCMediaSourceCellIdentifier";
+
+ at interface VLCMediaSourceCollectionViewItem ()
+
+ at end
+
+ at implementation VLCMediaSourceCollectionViewItem
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+
+    [self.mediaImageView setImage:[NSImage imageNamed:@"NSApplicationIcon"]];
+}
+
+ at end
diff --git a/modules/gui/macosx/media-source/VLCMediaSourceDataSource.h b/modules/gui/macosx/media-source/VLCMediaSourceDataSource.h
index d698fa749d..97bf803182 100644
--- a/modules/gui/macosx/media-source/VLCMediaSourceDataSource.h
+++ b/modules/gui/macosx/media-source/VLCMediaSourceDataSource.h
@@ -22,9 +22,16 @@
 
 #import <Cocoa/Cocoa.h>
 
+typedef NS_ENUM(NSInteger, VLCMediaSourceMode) {
+    VLCMediaSourceModeLAN,
+    VLCMediaSourceModeInternet,
+};
+
 NS_ASSUME_NONNULL_BEGIN
 
- at interface VLCMediaSourceDataSource : NSObject <NSTableViewDataSource, NSTableViewDelegate>
+ at interface VLCMediaSourceDataSource : NSObject <NSCollectionViewDataSource, NSCollectionViewDelegate>
+
+ at property (readwrite) VLCMediaSourceMode mediaSourceMode;
 
 @end
 
diff --git a/modules/gui/macosx/media-source/VLCMediaSourceDataSource.m b/modules/gui/macosx/media-source/VLCMediaSourceDataSource.m
index fee40f05ac..e5b14c22f3 100644
--- a/modules/gui/macosx/media-source/VLCMediaSourceDataSource.m
+++ b/modules/gui/macosx/media-source/VLCMediaSourceDataSource.m
@@ -24,14 +24,12 @@
 
 #import "media-source/VLCMediaSourceProvider.h"
 #import "media-source/VLCMediaSource.h"
-#import "playlist/VLCPlaylistTableCellView.h"
+#import "media-source/VLCMediaSourceCollectionViewItem.h"
 
 #import "main/VLCMain.h"
 #import "library/VLCInputItem.h"
 #import "extensions/NSString+Helpers.h"
 
-static NSString *VLCMediaSourceCellIdentifier = @"VLCMediaSourceCellIdentifier";
-
 @interface VLCMediaSourceDataSource ()
 {
     NSArray *_mediaDiscovery;
@@ -53,94 +51,60 @@ static NSString *VLCMediaSourceCellIdentifier = @"VLCMediaSourceCellIdentifier";
 
 - (void)lazyLoadMediaSources
 {
-    NSMutableArray *mutableArray = [[NSMutableArray alloc] init];
-    NSArray *mediaDiscoveryForDevices = [VLCMediaSourceProvider listOfMediaSourcesForCategory:SD_CAT_DEVICES];
-    if (mediaDiscoveryForDevices.count > 0) {
-        [mutableArray addObject:_NS("Devices")];
-        [mutableArray addObjectsFromArray:mediaDiscoveryForDevices];
-    }
-
     NSArray *mediaDiscoveryForLAN = [VLCMediaSourceProvider listOfMediaSourcesForCategory:SD_CAT_LAN];
-    if (mediaDiscoveryForLAN.count > 0) {
-        [mutableArray addObject:_NS("Local Network")];
-        [mutableArray addObjectsFromArray:mediaDiscoveryForLAN];
-    }
-
-    NSArray *mediaDiscoveryForInternet = [VLCMediaSourceProvider listOfMediaSourcesForCategory:SD_CAT_INTERNET];
-    if (mediaDiscoveryForInternet.count > 0) {
-        [mutableArray addObject:_NS("Internet")];
-        [mutableArray addObjectsFromArray:mediaDiscoveryForInternet];
-    }
-
-    NSArray *mediaDiscoveryForMyComputer = [VLCMediaSourceProvider listOfMediaSourcesForCategory:SD_CAT_MYCOMPUTER];
-    if (mediaDiscoveryForMyComputer.count > 0) {
-        [mutableArray addObject:_NS("My Computer")];
-        [mutableArray addObjectsFromArray:mediaDiscoveryForMyComputer];
+    NSUInteger count = mediaDiscoveryForLAN.count;
+    if (count > 0) {
+        for (NSUInteger x = 0; x < count; x++) {
+            VLCMediaSource *mediaSource = mediaDiscoveryForLAN[x];
+            VLCInputNode *rootNode = [mediaSource rootNode];
+            [mediaSource preparseInputItemWithinTree:rootNode.inputItem];
+        }
     }
-
-    _mediaDiscovery = [mutableArray copy];
+    _mediaDiscovery = mediaDiscoveryForLAN;
 }
 
-- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
+- (NSInteger)collectionView:(NSCollectionView *)collectionView
+     numberOfItemsInSection:(NSInteger)section
 {
-    return _mediaDiscovery.count;
+    switch (self.mediaSourceMode) {
+        case VLCMediaSourceModeLAN:
+            return _mediaDiscovery.count;
+            break;
+
+        case VLCMediaSourceModeInternet:
+        default:
+            return 0;
+            break;
+    }
 }
 
-- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
+- (NSCollectionViewItem *)collectionView:(NSCollectionView *)collectionView
+     itemForRepresentedObjectAtIndexPath:(NSIndexPath *)indexPath
 {
-    VLCPlaylistTableCellView *cellView = [tableView makeViewWithIdentifier:VLCMediaSourceCellIdentifier owner:self];
-
-    if (cellView == nil) {
-        /* the following code saves us an instance of NSViewController which we don't need */
-        NSNib *nib = [[NSNib alloc] initWithNibNamed:@"VLCPlaylistTableCellView" bundle:nil];
-        NSArray *topLevelObjects;
-        if (![nib instantiateWithOwner:self topLevelObjects:&topLevelObjects]) {
-            msg_Err(getIntf(), "Failed to load nib file to show playlist items");
-            return nil;
-        }
-
-        for (id topLevelObject in topLevelObjects) {
-            if ([topLevelObject isKindOfClass:[VLCPlaylistTableCellView class]]) {
-                cellView = topLevelObject;
-                break;
-            }
-        }
-        cellView.identifier = VLCMediaSourceCellIdentifier;
+    VLCMediaSourceCollectionViewItem *viewItem = [collectionView makeItemWithIdentifier:VLCMediaSourceCellIdentifier forIndexPath:indexPath];
+
+    NSArray *mediaArray;
+    switch (self.mediaSourceMode) {
+        case VLCMediaSourceModeLAN:
+            mediaArray = _mediaDiscovery;
+            break;
+
+        case VLCMediaSourceModeInternet:
+        default:
+            NSAssert(1, @"no representation for selected media source mode %li", (long)self.mediaSourceMode);
+            mediaArray = @[];
+            break;
     }
 
-    if ([self tableView:tableView isGroupRow:row]) {
-        NSString *labelString = _mediaDiscovery[row];
-        cellView.mediaTitleTextField.hidden = NO;
-        cellView.secondaryMediaTitleTextField.hidden = YES;
-        cellView.artistTextField.hidden = YES;
-        cellView.mediaTitleTextField.stringValue = labelString;
-        cellView.durationTextField.stringValue = @"";
-    } else {
-        VLCMediaSource *mediaSource = _mediaDiscovery[row];
-
-        VLCInputItem *inputItem = mediaSource.rootNode.inputItem;
-        if (inputItem) {
-            cellView.mediaTitleTextField.hidden = YES;
-            cellView.secondaryMediaTitleTextField.hidden = NO;
-            cellView.artistTextField.hidden = NO;
-            cellView.secondaryMediaTitleTextField.stringValue = mediaSource.mediaSourceDescription;
-            cellView.artistTextField.stringValue = inputItem.name;
-            cellView.durationTextField.stringValue = [NSString stringWithTimeFromTicks:inputItem.duration];
-        } else {
-            cellView.mediaTitleTextField.hidden = NO;
-            cellView.secondaryMediaTitleTextField.hidden = YES;
-            cellView.artistTextField.hidden = YES;
-            cellView.mediaTitleTextField.stringValue = mediaSource.mediaSourceDescription;
-            cellView.durationTextField.stringValue = @"";
-        }
-    }
+    VLCMediaSource *mediaSource = mediaArray[indexPath.item];
+    viewItem.titleTextField.stringValue = mediaSource.mediaSourceDescription;
 
-    return cellView;
+    return viewItem;
 }
 
-- (BOOL)tableView:(NSTableView *)tableView isGroupRow:(NSInteger)row
+- (void)collectionView:(NSCollectionView *)collectionView didSelectItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths
 {
-    return [_mediaDiscovery[row] isKindOfClass:[NSString class]];
+    NSLog(@"media source selection changed: %@", indexPaths);
 }
 
 @end
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 296db52688..596134165d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -489,6 +489,8 @@ modules/gui/macosx/main/VLCMain.m
 modules/gui/macosx/main/macosx.m
 modules/gui/macosx/media-source/VLCMediaSource.h
 modules/gui/macosx/media-source/VLCMediaSource.m
+modules/gui/macosx/media-source/VLCMediaSourceCollectionViewItem.h
+modules/gui/macosx/media-source/VLCMediaSourceCollectionViewItem.m
 modules/gui/macosx/media-source/VLCMediaSourceDataSource.h
 modules/gui/macosx/media-source/VLCMediaSourceDataSource.m
 modules/gui/macosx/media-source/VLCMediaSourceProvider.h




More information about the vlc-commits mailing list