[vlc-commits] macosx/library window: clean-up

Felix Paul Kühne git at videolan.org
Sun Jun 30 14:22:40 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sun Jun 30 13:58:54 2019 +0200| [726400ca0828f2b867fdfdea7a6ae763956c753e] | committer: Felix Paul Kühne

macosx/library window: clean-up

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

 modules/gui/macosx/library/VLCLibraryWindow.m                |  5 +----
 .../gui/macosx/media-source/VLCMediaSourceBaseDataSource.h   |  3 ++-
 .../gui/macosx/media-source/VLCMediaSourceBaseDataSource.m   | 12 ++++++++++--
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/modules/gui/macosx/library/VLCLibraryWindow.m b/modules/gui/macosx/library/VLCLibraryWindow.m
index 8efa886956..bf34c9982c 100644
--- a/modules/gui/macosx/library/VLCLibraryWindow.m
+++ b/modules/gui/macosx/library/VLCLibraryWindow.m
@@ -41,7 +41,6 @@
 #import "library/VLCLibraryAlternativeAudioViewController.h"
 #import "library/VLCLibrarySortingMenuController.h"
 
-#import "media-source/VLCMediaSourceCollectionViewItem.h"
 #import "media-source/VLCMediaSourceBaseDataSource.h"
 
 #import "views/VLCDragDropView.h"
@@ -240,9 +239,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
     _mediaSourceDataSource.collectionView = _mediaSourceCollectionView;
     _mediaSourceDataSource.homeButton = _mediaSourceHomeButton;
     _mediaSourceDataSource.pathControl = _mediaSourcePathControl;
-    _mediaSourceCollectionView.dataSource = _mediaSourceDataSource;
-    _mediaSourceCollectionView.delegate = _mediaSourceDataSource;
-    [_mediaSourceCollectionView registerClass:[VLCMediaSourceCollectionViewItem class] forItemWithIdentifier:VLCMediaSourceCellIdentifier];
+    [_mediaSourceDataSource setupViews];
 
     self.upNextLabel.font = [NSFont VLClibrarySectionHeaderFont];
     self.upNextLabel.stringValue = _NS("Playlist");
diff --git a/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.h b/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.h
index 8af7aeeaf4..5fbfb7b70a 100644
--- a/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.h
+++ b/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.h
@@ -24,12 +24,13 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
- at interface VLCMediaSourceBaseDataSource : NSObject <NSCollectionViewDataSource, NSCollectionViewDelegate>
+ at interface VLCMediaSourceBaseDataSource : NSObject
 
 @property (readwrite) NSCollectionView *collectionView;
 @property (readwrite) NSButton *homeButton;
 @property (readwrite) NSPathControl *pathControl;
 
+- (void)setupViews;
 - (void)loadMediaSources;
 
 @end
diff --git a/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.m b/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.m
index 0843758ef2..3f5ecdc433 100644
--- a/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.m
+++ b/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.m
@@ -28,10 +28,11 @@
 #import "media-source/VLCMediaSourceDataSource.h"
 
 #import "main/VLCMain.h"
+#import "views/VLCImageView.h"
 #import "library/VLCInputItem.h"
 #import "extensions/NSString+Helpers.h"
 
- at interface VLCMediaSourceBaseDataSource ()
+ at interface VLCMediaSourceBaseDataSource () <NSCollectionViewDataSource, NSCollectionViewDelegate>
 {
     NSArray *_mediaSources;
     VLCMediaSourceDataSource *_childDataSource;
@@ -67,12 +68,19 @@
     [[NSNotificationCenter defaultCenter] removeObserver:self];
 }
 
-- (void)loadMediaSources
+- (void)setupViews
 {
+    self.collectionView.dataSource = self;
+    self.collectionView.delegate = self;
+    [self.collectionView registerClass:[VLCMediaSourceCollectionViewItem class] forItemWithIdentifier:VLCMediaSourceCellIdentifier];
+
     self.homeButton.action = @selector(homeButtonAction:);
     self.homeButton.target = self;
     self.pathControl.URL = nil;
+}
 
+- (void)loadMediaSources
+{
     NSArray *mediaSourcesOnLAN = [VLCMediaSourceProvider listOfMediaSourcesForCategory:SD_CAT_LAN];
     NSUInteger count = mediaSourcesOnLAN.count;
     if (count > 0) {



More information about the vlc-commits mailing list