[vlc-commits] macosx/library: show recently played media and introduce section headers

Felix Paul Kühne git at videolan.org
Mon May 6 08:25:21 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Mon May  6 08:23:46 2019 +0200| [510805b252b5185413056e07314b14ccfb32a8a0] | committer: Felix Paul Kühne

macosx/library: show recently played media and introduce section headers

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

 .../package/macosx/VLC.xcodeproj/project.pbxproj   |  6 ++
 modules/gui/macosx/Makefile.am                     |  2 +
 ...LibraryCollectionViewSupplementaryElementView.h | 35 ++++++++++++
 ...LibraryCollectionViewSupplementaryElementView.m | 57 +++++++++++++++++++
 modules/gui/macosx/library/VLCLibraryDataSource.m  | 55 +++++++++++++++----
 modules/gui/macosx/library/VLCLibraryModel.h       |  4 ++
 modules/gui/macosx/library/VLCLibraryModel.m       | 64 ++++++++++++++++++++--
 modules/gui/macosx/library/VLCLibraryWindow.m      |  9 +++
 modules/gui/macosx/main/CompatibilityFixes.m       |  6 ++
 po/POTFILES.in                                     |  2 +
 10 files changed, 225 insertions(+), 15 deletions(-)

diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
index 6e7538ffa8..74fa01979c 100644
--- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj
+++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
@@ -149,6 +149,7 @@
 		7DB7F20720CC07E600C2CAED /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7DB7F20620CC07E600C2CAED /* SystemConfiguration.framework */; };
 		7DB7F20920CC07FD00C2CAED /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7DB7F20820CC07FD00C2CAED /* WebKit.framework */; };
 		7DB7F20B20CC082800C2CAED /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7DB7F20A20CC082800C2CAED /* QuartzCore.framework */; };
+		7DBB7639227F3FBC002649E1 /* VLCLibraryCollectionViewSupplementaryElementView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DBB7638227F3FBC002649E1 /* VLCLibraryCollectionViewSupplementaryElementView.m */; };
 		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 */; };
@@ -523,6 +524,8 @@
 		7DB7F20820CC07FD00C2CAED /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
 		7DB7F20A20CC082800C2CAED /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
 		7DBB06631CC2314D004C74D2 /* caopengllayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = caopengllayer.m; path = ../../../modules/video_output/caopengllayer.m; sourceTree = "<group>"; };
+		7DBB7637227F3FBC002649E1 /* VLCLibraryCollectionViewSupplementaryElementView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryCollectionViewSupplementaryElementView.h; sourceTree = "<group>"; };
+		7DBB7638227F3FBC002649E1 /* VLCLibraryCollectionViewSupplementaryElementView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryCollectionViewSupplementaryElementView.m; sourceTree = "<group>"; };
 		7DC21A7222049A6600F98A02 /* VLCOpenInputMetadata.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCOpenInputMetadata.h; sourceTree = "<group>"; };
 		7DC21A7322049A6600F98A02 /* VLCOpenInputMetadata.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCOpenInputMetadata.m; sourceTree = "<group>"; };
 		7DD2F5C32081B73B007EE187 /* VLCRemoteControlService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCRemoteControlService.h; sourceTree = "<group>"; };
@@ -971,6 +974,8 @@
 			children = (
 				7D0F64032202047900FDB91F /* VLCLibraryCollectionViewItem.h */,
 				7D0F64042202047900FDB91F /* VLCLibraryCollectionViewItem.m */,
+				7DBB7637227F3FBC002649E1 /* VLCLibraryCollectionViewSupplementaryElementView.h */,
+				7DBB7638227F3FBC002649E1 /* VLCLibraryCollectionViewSupplementaryElementView.m */,
 				7D713D302201AE350042BEB7 /* VLCLibraryWindow.h */,
 				7D713D312201AE350042BEB7 /* VLCLibraryWindow.m */,
 				7DFBDCA62269E77400B700A5 /* VLCLibraryController.h */,
@@ -1656,6 +1661,7 @@
 				7DD2F5C52081B73B007EE187 /* VLCRemoteControlService.m in Sources */,
 				1C31139F1E508C6900D4DD76 /* VLCMainWindowControlsBar.m in Sources */,
 				1C3113A11E508C6900D4DD76 /* VLCConvertAndSaveWindowController.m in Sources */,
+				7DBB7639227F3FBC002649E1 /* VLCLibraryCollectionViewSupplementaryElementView.m in Sources */,
 				1C3113A31E508C6900D4DD76 /* VLCCoreDialogProvider.m in Sources */,
 				6B2EFC631F281A0900F3C0EA /* VLCVolumeSliderCell.m in Sources */,
 				1C3113A71E508C6900D4DD76 /* VLCLogWindowController.m in Sources */,
diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am
index 92af812533..84c887b340 100644
--- a/modules/gui/macosx/Makefile.am
+++ b/modules/gui/macosx/Makefile.am
@@ -52,6 +52,8 @@ libmacosx_plugin_la_SOURCES = \
 	gui/macosx/library/VLCInputItem.m \
 	gui/macosx/library/VLCLibraryCollectionViewItem.h \
 	gui/macosx/library/VLCLibraryCollectionViewItem.m \
+	gui/macosx/library/VLCLibraryCollectionViewSupplementaryElementView.h \
+	gui/macosx/library/VLCLibraryCollectionViewSupplementaryElementView.m \
 	gui/macosx/library/VLCLibraryController.h \
 	gui/macosx/library/VLCLibraryController.m \
 	gui/macosx/library/VLCLibraryDataSource.h \
diff --git a/modules/gui/macosx/library/VLCLibraryCollectionViewSupplementaryElementView.h b/modules/gui/macosx/library/VLCLibraryCollectionViewSupplementaryElementView.h
new file mode 100644
index 0000000000..d693e90733
--- /dev/null
+++ b/modules/gui/macosx/library/VLCLibraryCollectionViewSupplementaryElementView.h
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * VLCLibraryCollectionViewSupplementaryElementView.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
+
+extern NSString *VLCLibrarySupplementaryElementViewIdentifier;
+
+ at interface VLCLibraryCollectionViewSupplementaryElementView : NSTextField
+
++ (CGSize)defaultHeaderSize;
+
+ at end
+
+NS_ASSUME_NONNULL_END
diff --git a/modules/gui/macosx/library/VLCLibraryCollectionViewSupplementaryElementView.m b/modules/gui/macosx/library/VLCLibraryCollectionViewSupplementaryElementView.m
new file mode 100644
index 0000000000..1eda8d31d5
--- /dev/null
+++ b/modules/gui/macosx/library/VLCLibraryCollectionViewSupplementaryElementView.m
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * VLCLibraryCollectionViewSupplementaryElementView.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 "VLCLibraryCollectionViewSupplementaryElementView.h"
+#import "extensions/NSFont+VLCAdditions.h"
+#import "extensions/NSColor+VLCAdditions.h"
+
+NSString *VLCLibrarySupplementaryElementViewIdentifier = @"VLCLibrarySupplementaryElementViewIdentifier";
+
+ at implementation VLCLibraryCollectionViewSupplementaryElementView
+
++ (CGSize)defaultHeaderSize
+{
+    return CGSizeMake(100., 40.);
+}
+
+- (instancetype)initWithFrame:(NSRect)frameRect
+{
+    self = [super initWithFrame:frameRect];
+    if (self) {
+        self.font = [NSFont VLClibrarySectionHeaderFont];
+        if (@available(macOS 10_14, *)) {
+            self.textColor = [self.effectiveAppearance.name isEqualToString:NSAppearanceNameDarkAqua] ? [NSColor VLClibraryDarkTitleColor] : [NSColor VLClibraryLightTitleColor];
+        } else {
+            self.textColor = [NSColor VLClibraryLightTitleColor];
+        }
+        self.editable = NO;
+        self.selectable = NO;
+    }
+    return self;
+}
+
+- (void)viewDidChangeEffectiveAppearance
+{
+    self.textColor = [self.effectiveAppearance.name isEqualToString:NSAppearanceNameDarkAqua] ? [NSColor VLClibraryDarkTitleColor] : [NSColor VLClibraryLightTitleColor];
+}
+
+ at end
diff --git a/modules/gui/macosx/library/VLCLibraryDataSource.m b/modules/gui/macosx/library/VLCLibraryDataSource.m
index ae49c686da..8f6d04726f 100644
--- a/modules/gui/macosx/library/VLCLibraryDataSource.m
+++ b/modules/gui/macosx/library/VLCLibraryDataSource.m
@@ -23,13 +23,21 @@
 #import "VLCLibraryDataSource.h"
 
 #import "library/VLCLibraryCollectionViewItem.h"
+#import "library/VLCLibraryCollectionViewSupplementaryElementView.h"
 #import "library/VLCLibraryModel.h"
 
+#import "main/CompatibilityFixes.h"
+#import "extensions/NSString+Helpers.h"
+
 @implementation VLCLibraryDataSource
 
 - (NSInteger)collectionView:(NSCollectionView *)collectionView
      numberOfItemsInSection:(NSInteger)section
 {
+    if (_libraryModel.numberOfRecentMedia && section == 0) {
+        return [_libraryModel numberOfRecentMedia];
+    }
+
     switch (_libraryModel.libraryMode) {
         case VLCLibraryModeAudio:
             return [_libraryModel numberOfAudioMedia];
@@ -37,6 +45,7 @@
 
         case VLCLibraryModeVideo:
             return [_libraryModel numberOfVideoMedia];
+            break;
 
         default:
             return 0;
@@ -44,25 +53,34 @@
     }
 }
 
+- (NSInteger)numberOfSectionsInCollectionView:(NSCollectionView *)collectionView
+{
+    return _libraryModel.numberOfRecentMedia > 0 ? 2 : 1;
+}
+
 - (NSCollectionViewItem *)collectionView:(NSCollectionView *)collectionView
      itemForRepresentedObjectAtIndexPath:(NSIndexPath *)indexPath
 {
     VLCLibraryCollectionViewItem *viewItem = [collectionView makeItemWithIdentifier:VLCLibraryCellIdentifier forIndexPath:indexPath];
 
     NSArray *mediaArray;
-    switch (_libraryModel.libraryMode) {
-        case VLCLibraryModeAudio:
-            mediaArray = [_libraryModel listOfAudioMedia];
-            break;
+    if (indexPath.section == 0 && _libraryModel.numberOfRecentMedia > 0) {
+        mediaArray = [_libraryModel listOfRecentMedia];
+    } else {
+        switch (_libraryModel.libraryMode) {
+            case VLCLibraryModeAudio:
+                mediaArray = [_libraryModel listOfAudioMedia];
+                break;
 
-        case VLCLibraryModeVideo:
-            mediaArray = [_libraryModel listOfVideoMedia];
-            break;
+            case VLCLibraryModeVideo:
+                mediaArray = [_libraryModel listOfVideoMedia];
+                break;
 
-        default:
-            NSAssert(1, @"no representation for selected library mode");
-            mediaArray = @[];
-            break;
+            default:
+                NSAssert(1, @"no representation for selected library mode");
+                mediaArray = @[];
+                break;
+        }
     }
 
     viewItem.representedMediaItem = mediaArray[indexPath.item];
@@ -70,6 +88,21 @@
     return viewItem;
 }
 
+- (NSView *)collectionView:(NSCollectionView *)collectionView
+viewForSupplementaryElementOfKind:(NSCollectionViewSupplementaryElementKind)kind
+               atIndexPath:(NSIndexPath *)indexPath
+{
+    VLCLibraryCollectionViewSupplementaryElementView *view = [collectionView makeSupplementaryViewOfKind:kind
+                                                                                          withIdentifier:VLCLibrarySupplementaryElementViewIdentifier
+                                                                                            forIndexPath:indexPath];
+    if (indexPath.section == 0 && _libraryModel.numberOfRecentMedia > 0) {
+        view.stringValue = _NS("Recent");
+    } else {
+        view.stringValue = _NS("Library");
+    }
+    return view;
+}
+
 - (void)collectionView:(NSCollectionView *)collectionView didSelectItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths
 {
     NSLog(@"library selection changed: %@", indexPaths);
diff --git a/modules/gui/macosx/library/VLCLibraryModel.h b/modules/gui/macosx/library/VLCLibraryModel.h
index 4bb13f9128..fabeb3bcb7 100644
--- a/modules/gui/macosx/library/VLCLibraryModel.h
+++ b/modules/gui/macosx/library/VLCLibraryModel.h
@@ -36,6 +36,7 @@ typedef NS_ENUM(NSInteger, VLCLibraryMode) {
 
 extern NSString *VLCLibraryModelAudioMediaListUpdated;
 extern NSString *VLCLibraryModelVideoMediaListUpdated;
+extern NSString *VLCLibraryModelRecentMediaListUpdated;
 extern NSString *VLCLibraryModelMediaItemUpdated;
 
 @interface VLCLibraryModel : NSObject
@@ -50,6 +51,9 @@ extern NSString *VLCLibraryModelMediaItemUpdated;
 @property (readonly) size_t numberOfVideoMedia;
 @property (readonly) NSArray <VLCMediaLibraryMediaItem *> *listOfVideoMedia;
 
+ at property (readonly) size_t numberOfRecentMedia;
+ at property (readonly) NSArray <VLCMediaLibraryMediaItem *> *listOfRecentMedia;
+
 - (nullable VLCMediaLibraryMediaItem *)mediaItemAtIndexPath:(NSIndexPath *)index;
 
 @property (readonly) NSArray <VLCMediaLibraryEntryPoint *> *listOfMonitoredFolders;
diff --git a/modules/gui/macosx/library/VLCLibraryModel.m b/modules/gui/macosx/library/VLCLibraryModel.m
index 35c8c8fbb6..cd68a0b1e1 100644
--- a/modules/gui/macosx/library/VLCLibraryModel.m
+++ b/modules/gui/macosx/library/VLCLibraryModel.m
@@ -27,6 +27,7 @@
 
 NSString *VLCLibraryModelAudioMediaListUpdated = @"VLCLibraryModelAudioMediaListUpdated";
 NSString *VLCLibraryModelVideoMediaListUpdated = @"VLCLibraryModelVideoMediaListUpdated";
+NSString *VLCLibraryModelRecentMediaListUpdated = @"VLCLibraryModelRecentMediaListUpdated";
 NSString *VLCLibraryModelMediaItemUpdated = @"VLCLibraryModelMediaItemUpdated";
 
 @interface VLCLibraryModel ()
@@ -36,11 +37,13 @@ NSString *VLCLibraryModelMediaItemUpdated = @"VLCLibraryModelMediaItemUpdated";
 
     NSArray *_cachedAudioMedia;
     NSArray *_cachedVideoMedia;
+    NSArray *_cachedRecentMedia;
     NSNotificationCenter *_defaultNotificationCenter;
 }
 
 - (void)updateCachedListOfAudioMedia;
 - (void)updateCachedListOfVideoMedia;
+- (void)updateCachedListOfRecentMedia;
 - (void)mediaItemWasUpdated:(VLCMediaLibraryMediaItem *)mediaItem;
 
 @end
@@ -56,14 +59,17 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
                 VLCLibraryModel *libraryModel = (__bridge VLCLibraryModel *)p_data;
                 switch (libraryModel.libraryMode) {
                     case VLCLibraryModeAudio:
+                        [libraryModel updateCachedListOfRecentMedia];
                         [libraryModel updateCachedListOfAudioMedia];
                         break;
 
                     case VLCLibraryModeVideo:
+                        [libraryModel updateCachedListOfRecentMedia];
                         [libraryModel updateCachedListOfVideoMedia];
                         break;
 
                     default:
+                        [libraryModel updateCachedListOfRecentMedia];
                         break;
                 }
 
@@ -120,7 +126,9 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
 - (size_t)numberOfAudioMedia
 {
     if (_cachedAudioMedia) {
-        [self updateCachedListOfAudioMedia];
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [self updateCachedListOfAudioMedia];
+        });
     }
 
     return _cachedAudioMedia.count;
@@ -142,7 +150,9 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
 - (NSArray<VLCMediaLibraryMediaItem *> *)listOfAudioMedia
 {
     if (!_cachedAudioMedia) {
-        [self updateCachedListOfAudioMedia];
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [self updateCachedListOfAudioMedia];
+        });
     }
 
     return _cachedAudioMedia;
@@ -151,7 +161,9 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
 - (size_t)numberOfVideoMedia
 {
     if (!_cachedVideoMedia) {
-        [self updateCachedListOfVideoMedia];
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [self updateCachedListOfVideoMedia];
+        });
     }
 
     return _cachedVideoMedia.count;
@@ -175,6 +187,10 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
 
 - (nullable VLCMediaLibraryMediaItem *)mediaItemAtIndexPath:(NSIndexPath *)indexPath
 {
+    if (_cachedRecentMedia.count > 0 && indexPath.section == 0) {
+        return _cachedRecentMedia[indexPath.item];
+    }
+
     // FIXME: the scope needs be larger than just the video list
     if (!_cachedVideoMedia) {
         return nil;
@@ -185,12 +201,52 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
 - (NSArray<VLCMediaLibraryMediaItem *> *)listOfVideoMedia
 {
     if (!_cachedVideoMedia) {
-        [self updateCachedListOfVideoMedia];
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [self updateCachedListOfVideoMedia];
+        });
     }
 
     return _cachedVideoMedia;
 }
 
+- (void)updateCachedListOfRecentMedia
+{
+    vlc_ml_media_list_t *p_media_list = vlc_ml_list_history(_p_mediaLibrary, NULL);
+    if (p_media_list == NULL) {
+        return;
+    }
+    NSMutableArray *mutableArray = [[NSMutableArray alloc] initWithCapacity:p_media_list->i_nb_items];
+    for (size_t x = 0; x < p_media_list->i_nb_items; x++) {
+        VLCMediaLibraryMediaItem *mediaItem = [[VLCMediaLibraryMediaItem alloc] initWithMediaItem:&p_media_list->p_items[x]];
+        [mutableArray addObject:mediaItem];
+    }
+    _cachedRecentMedia = [mutableArray copy];
+    vlc_ml_media_list_release(p_media_list);
+    [_defaultNotificationCenter postNotificationName:VLCLibraryModelRecentMediaListUpdated object:self];
+}
+
+- (size_t)numberOfRecentMedia
+{
+    if (!_cachedRecentMedia) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [self updateCachedListOfRecentMedia];
+        });
+    }
+
+    return _cachedRecentMedia.count;
+}
+
+- (NSArray<VLCMediaLibraryMediaItem *> *)listOfRecentMedia
+{
+    if (!_cachedRecentMedia) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [self updateCachedListOfRecentMedia];
+        });
+    }
+
+    return _cachedRecentMedia;
+}
+
 - (NSArray<VLCMediaLibraryEntryPoint *> *)listOfMonitoredFolders
 {
     vlc_ml_entry_point_list_t *pp_entrypoints;
diff --git a/modules/gui/macosx/library/VLCLibraryWindow.m b/modules/gui/macosx/library/VLCLibraryWindow.m
index e56e21d21a..f3d754e024 100644
--- a/modules/gui/macosx/library/VLCLibraryWindow.m
+++ b/modules/gui/macosx/library/VLCLibraryWindow.m
@@ -36,6 +36,7 @@
 #import "library/VLCLibraryCollectionViewItem.h"
 #import "library/VLCLibraryModel.h"
 #import "library/VLCLibraryMenuController.h"
+#import "library/VLCLibraryCollectionViewSupplementaryElementView.h"
 
 #import "media-source/VLCMediaSourceCollectionViewItem.h"
 #import "media-source/VLCMediaSourceDataSource.h"
@@ -83,6 +84,10 @@ static const float f_playlist_row_height = 72.;
                                name:VLCLibraryModelVideoMediaListUpdated
                              object:nil];
     [notificationCenter addObserver:self
+                           selector:@selector(updateLibraryRepresentation:)
+                               name:VLCLibraryModelRecentMediaListUpdated
+                             object:nil];
+    [notificationCenter addObserver:self
                            selector:@selector(shuffleStateUpdated:)
                                name:VLCPlaybackOrderChanged
                              object:nil];
@@ -126,6 +131,10 @@ static const float f_playlist_row_height = 72.;
     _libraryCollectionView.dataSource = _libraryDataSource;
     _libraryCollectionView.delegate = _libraryDataSource;
     [_libraryCollectionView registerClass:[VLCLibraryCollectionViewItem class] forItemWithIdentifier:VLCLibraryCellIdentifier];
+    [_libraryCollectionView registerClass:[VLCLibraryCollectionViewSupplementaryElementView class]
+               forSupplementaryViewOfKind:NSCollectionElementKindSectionHeader
+                           withIdentifier:VLCLibrarySupplementaryElementViewIdentifier];
+    [(NSCollectionViewFlowLayout *)_libraryCollectionView.collectionViewLayout setHeaderReferenceSize:[VLCLibraryCollectionViewSupplementaryElementView defaultHeaderSize]];
 
     _mediaSourceDataSource = [[VLCMediaSourceDataSource alloc] init];
     _mediaSourceDataSource.collectionView = _mediaSourceCollectionView;
diff --git a/modules/gui/macosx/main/CompatibilityFixes.m b/modules/gui/macosx/main/CompatibilityFixes.m
index fb84c1bcee..7ca12d1d95 100644
--- a/modules/gui/macosx/main/CompatibilityFixes.m
+++ b/modules/gui/macosx/main/CompatibilityFixes.m
@@ -48,3 +48,9 @@ void swapoutOverride(Class cls, SEL selector)
 NSString *const NSAppearanceNameDarkAqua = @"NSAppearanceNameDarkAqua";
 
 #endif
+
+#ifndef MAC_OS_X_VERSION_10_13
+
+NSString *const NSCollectionViewSupplementaryElementKind = @"NSCollectionViewSupplementaryElementKind";
+
+#endif
diff --git a/po/POTFILES.in b/po/POTFILES.in
index aa78d72322..a665fbd8d4 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -470,6 +470,8 @@ modules/gui/macosx/library/VLCInputItem.h
 modules/gui/macosx/library/VLCInputItem.m
 modules/gui/macosx/library/VLCLibraryCollectionViewItem.h
 modules/gui/macosx/library/VLCLibraryCollectionViewItem.m
+modules/gui/macosx/library/VLCLibraryCollectionViewSupplementaryElementView.h
+modules/gui/macosx/library/VLCLibraryCollectionViewSupplementaryElementView.m
 modules/gui/macosx/library/VLCLibraryController.h
 modules/gui/macosx/library/VLCLibraryController.m
 modules/gui/macosx/library/VLCLibraryDataSource.h



More information about the vlc-commits mailing list