[vlc-commits] [Git][videolan/vlc][master] macosx: Enable 'Reveal in Finder' feature for albums, artists, and genres

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Mon Jul 25 10:41:49 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
18281a51 by Claudio Cambra at 2022-07-25T10:41:40+00:00
macosx: Enable 'Reveal in Finder' feature for albums, artists, and genres

- - - - -


3 changed files:

- modules/gui/macosx/library/VLCLibraryDataTypes.h
- modules/gui/macosx/library/VLCLibraryDataTypes.m
- modules/gui/macosx/library/VLCLibraryMenuController.m


Changes:

=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.h
=====================================
@@ -121,6 +121,7 @@ extern const long long int VLCMediaLibraryMediaItemDurationDenominator;
 @property (readonly) unsigned int numberOfAlbums;
 @property (readonly) unsigned int numberOfTracks;
 @property (readonly) NSArray <VLCMediaLibraryAlbum *> *albums;
+ at property (readonly) NSArray <VLCMediaLibraryMediaItem *> *tracksAsMediaItems;
 
 @end
 


=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.m
=====================================
@@ -265,6 +265,31 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
     return [mutableArray copy];
 }
 
+- (NSArray<VLCMediaLibraryMediaItem *> *)tracksAsMediaItems
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf) {
+        return @[];
+    }
+    vlc_medialibrary_t *p_mediaLibrary = vlc_ml_instance_get(p_intf);
+    if (!p_mediaLibrary) {
+        return @[];
+    }
+    vlc_ml_media_list_t *p_mediaList = vlc_ml_list_artist_tracks(p_mediaLibrary, NULL, _artistID);
+    NSMutableArray *mutableArray = [[NSMutableArray alloc] initWithCapacity:p_mediaList->i_nb_items];
+    for (size_t x = 0; x < p_mediaList->i_nb_items; x++) {
+        VLCMediaLibraryMediaItem *mediaItem = [[VLCMediaLibraryMediaItem alloc] initWithMediaItem:&p_mediaList->p_items[x]];
+        [mutableArray addObject:mediaItem];
+    }
+    vlc_ml_media_list_release(p_mediaList);
+    return [mutableArray copy];
+}
+
+- (VLCMediaLibraryMediaItem *)firstMediaItem
+{
+    return [[self tracksAsMediaItems] firstObject];
+}
+
 - (void)iterateMediaItemsWithBlock:(void (^)(VLCMediaLibraryMediaItem*))mediaItemBlock;
 {
     for(VLCMediaLibraryAlbum* album in self.albums) {
@@ -331,6 +356,11 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
     return [mutableArray copy];
 }
 
+- (VLCMediaLibraryMediaItem *)firstMediaItem
+{
+    return [[self tracksAsMediaItems] firstObject];
+}
+
 - (void)iterateMediaItemsWithBlock:(void (^)(VLCMediaLibraryMediaItem*))mediaItemBlock
 {
     for(VLCMediaLibraryMediaItem* mediaItem in self.tracksAsMediaItems) {
@@ -434,6 +464,11 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
     return [mutableArray copy];
 }
 
+- (VLCMediaLibraryMediaItem *)firstMediaItem
+{
+    return [[self tracksAsMediaItems] firstObject];
+}
+
 - (void)iterateMediaItemsWithBlock:(void (^)(VLCMediaLibraryMediaItem*))mediaItemBlock
 {
     // By default iterate album-by-album
@@ -726,6 +761,11 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
     return inputItem;
 }
 
+- (VLCMediaLibraryMediaItem *)firstMediaItem
+{
+    return self;
+}
+
 - (void)iterateMediaItemsWithBlock:(void (^)(VLCMediaLibraryMediaItem*))mediaItemBlock;
 {
     mediaItemBlock(self);


=====================================
modules/gui/macosx/library/VLCLibraryMenuController.m
=====================================
@@ -126,11 +126,10 @@
         return;
     }
 
-    // TODO: Add handling for other types
-    if([_representedItem isKindOfClass:[VLCMediaLibraryMediaItem class]]) {
-        [_representedItem iterateMediaItemsWithBlock:^(VLCMediaLibraryMediaItem* mediaItem) {
-            [[[VLCMain sharedInstance] libraryController] showItemInFinder:mediaItem];
-        }];
+    VLCMediaLibraryMediaItem *firstMediaItem = _representedItem.firstMediaItem;
+
+    if(firstMediaItem) {
+        [[[VLCMain sharedInstance] libraryController] showItemInFinder:firstMediaItem];
     }
 }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/18281a518ed3f81b6c37accb697c52348a19f813

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/18281a518ed3f81b6c37accb697c52348a19f813
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list