[vlc-commits] [Git][videolan/vlc][master] 11 commits: macosx: Add isLibraryMeantToBeAvailable property to library controller

Steve Lhomme (@robUx4) gitlab at videolan.org
Sun May 3 07:39:06 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
102cc5fd by Claudio Cambra at 2026-05-03T07:14:54+00:00
macosx: Add isLibraryMeantToBeAvailable property to library controller

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
53930451 by Claudio Cambra at 2026-05-03T07:14:54+00:00
macosx: Do not show media library modal if VLC does not have media library module

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
6a898491 by Claudio Cambra at 2026-05-03T07:14:54+00:00
macosx: Hide media library settings segment if the media library is not bundled

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
d5effb55 by Claudio Cambra at 2026-05-03T07:14:54+00:00
macosx: Hide media library-related sidebar entries if the media library is not expected to be available

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
43fc67e8 by Claudio Cambra at 2026-05-03T07:14:54+00:00
macosx: Fall back to browse node if the segment is not available

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
e0125028 by Claudio Cambra at 2026-05-03T07:14:54+00:00
macosx: Do not attempt to get library instance if it is known the media library module is unavailable

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
567e28db by Claudio Cambra at 2026-05-03T07:14:54+00:00
macosx: Do not attempt to instantiate bookmarks window controller if media library unavailable

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
c1ca4864 by Claudio Cambra at 2026-05-03T07:14:54+00:00
macosx: Disable library-related menu entries when media library unavailable

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
ef885d08 by Claudio Cambra at 2026-05-03T07:14:54+00:00
macosx: Disable main video view buttons if library unavailable, hide if meant to be unavailable

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
034b8ced by Claudio Cambra at 2026-05-03T07:14:54+00:00
macosx: Disable media library settings segment if the media library isn't available

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
7b9ac8a3 by Claudio Cambra at 2026-05-03T07:14:54+00:00
macosx: Rename isMediaLibraryMeantToBeAvailable to shouldUseMediaLibrary

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


8 changed files:

- modules/gui/macosx/library/VLCLibraryController.h
- modules/gui/macosx/library/VLCLibraryController.m
- modules/gui/macosx/library/VLCLibrarySegment.m
- modules/gui/macosx/library/VLCLibraryWindowNavigationSidebarViewController.m
- modules/gui/macosx/main/VLCMain.m
- modules/gui/macosx/menus/VLCMainMenu.m
- modules/gui/macosx/preferences/VLCSimplePrefsController.m
- modules/gui/macosx/windows/controlsbar/VLCMainVideoViewControlsBar.m


Changes:

=====================================
modules/gui/macosx/library/VLCLibraryController.h
=====================================
@@ -33,6 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface VLCLibraryController : NSObject
 
+ at property (readonly) BOOL shouldUseMediaLibrary;
 @property (readonly, nullable) VLCLibraryModel *libraryModel;
 
 - (int)appendItemToPlayQueue:(VLCMediaLibraryMediaItem *)mediaItem


=====================================
modules/gui/macosx/library/VLCLibraryController.m
=====================================
@@ -38,6 +38,7 @@
 #import "playqueue/VLCPlayQueueModel.h"
 
 #import <vlc_media_library.h>
+#import <vlc_modules.h>
 
 typedef int (*folder_action_f)(vlc_medialibrary_t*, const char*);
 
@@ -53,8 +54,13 @@ typedef int (*folder_action_f)(vlc_medialibrary_t*, const char*);
 {
     self = [super init];
     if (self) {
-        _p_libraryInstance = vlc_ml_instance_get(getIntf());
-        if (!_p_libraryInstance) {
+        if (self.shouldUseMediaLibrary) {
+            _p_libraryInstance = vlc_ml_instance_get(getIntf());
+        } else {
+            return self;
+        }
+
+        if (!_p_libraryInstance && self.shouldUseMediaLibrary) {
             msg_Info(getIntf(), "VLC runs without media library support");
 
             NSUserDefaults * const defaults = NSUserDefaults.standardUserDefaults;
@@ -403,4 +409,9 @@ typedef int (*folder_action_f)(vlc_medialibrary_t*, const char*);
     self.libraryModel.filterString = filterString;
 }
 
+- (BOOL)shouldUseMediaLibrary
+{
+    return module_exists("medialibrary") && var_InheritBool(getIntf(), "media-library");
+}
+
 @end


=====================================
modules/gui/macosx/library/VLCLibrarySegment.m
=====================================
@@ -22,6 +22,8 @@
 
 #import "VLCLibrarySegment.h"
 
+#import "main/VLCMain.h"
+
 #import "extensions/NSImage+VLCAdditions.h"
 #import "extensions/NSString+Helpers.h"
 
@@ -50,7 +52,7 @@
 
 #import "library/video-library/VLCLibraryVideoViewController.h"
 
-#import "main/VLCMain.h"
+#import <vlc_modules.h>
 
 NSString * const VLCLibraryBookmarkedLocationsKey = @"VLCLibraryBookmarkedLocations";
 NSString * const VLCLibraryBookmarkedLocationsChanged = @"VLCLibraryBookmarkedLocationsChanged";
@@ -909,18 +911,27 @@ NSArray<NSString *> *defaultBookmarkedLocations()
 
 + (NSArray<VLCLibrarySegment *> *)librarySegments
 {
-    return @[
-        [[VLCLibraryHomeSegment alloc] init],
-        [[VLCLibraryHeaderSegment alloc] initWithDisplayString:_NS("Library")],
-        [[VLCLibraryFavoritesSegment alloc] init],
-        [[VLCLibraryVideoSegment alloc] init],
-        [[VLCLibraryMusicSegment alloc] init],
-        [[VLCLibraryPlaylistSegment alloc] init],
-        [[VLCLibraryGroupSegment alloc] init],
+    NSMutableArray *segments = [NSMutableArray array];
+
+    if (VLCMain.sharedInstance.libraryController.shouldUseMediaLibrary) {
+        [segments addObjectsFromArray:@[
+            [[VLCLibraryHomeSegment alloc] init],
+            [[VLCLibraryHeaderSegment alloc] initWithDisplayString:_NS("Library")],
+            [[VLCLibraryFavoritesSegment alloc] init],
+            [[VLCLibraryVideoSegment alloc] init],
+            [[VLCLibraryMusicSegment alloc] init],
+            [[VLCLibraryPlaylistSegment alloc] init],
+            [[VLCLibraryGroupSegment alloc] init]
+        ]];
+    }
+
+    [segments addObjectsFromArray:@[
         [[VLCLibraryHeaderSegment alloc] initWithDisplayString:_NS("Explore")],
         [[VLCLibraryBrowseSegment alloc] init],
         [[VLCLibraryStreamsSegment alloc] init],
-    ];
+    ]];
+
+    return segments.copy;
 }
 
 + (instancetype)segmentWithSegmentType:(VLCLibrarySegmentType)segmentType


=====================================
modules/gui/macosx/library/VLCLibraryWindowNavigationSidebarViewController.m
=====================================
@@ -287,7 +287,6 @@ static NSString * const VLCLibrarySegmentCellIdentifier = @"VLCLibrarySegmentCel
 
         nodes = nextLevelNodes.copy;
     }
-    NSAssert(NO, @"Could not find node for segment type %ld", segmentType);
     return nil;
 }
 
@@ -321,13 +320,19 @@ static NSString * const VLCLibrarySegmentCellIdentifier = @"VLCLibrarySegmentCel
         segmentType = VLCLibraryBrowseSegmentType;
     }
 
+    NSTreeNode *targetNode = [self nodeForSegmentType:segmentType];
+    if (targetNode == nil) {
+        // Fallback to Browse if the segment is not available
+        segmentType = VLCLibraryBrowseSegmentType;
+        targetNode = [self nodeForSegmentType:segmentType];
+    }
+
     self.libraryWindow.librarySegmentType = segmentType;
 
     if (segmentType == VLCLibraryMusicSegmentType) {
         [self.outlineView expandItem:[self nodeForSegmentType:VLCLibraryMusicSegmentType]];
     }
 
-    NSTreeNode * const targetNode = [self nodeForSegmentType:segmentType];
     const NSInteger segmentIndex = [self.outlineView rowForItem:targetNode];
     [self expandParentsOfNode:targetNode];
     [self.outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:segmentIndex]


=====================================
modules/gui/macosx/main/VLCMain.m
=====================================
@@ -550,6 +550,10 @@ static VLCMain *sharedInstance = nil;
 
 - (VLCBookmarksWindowController *)bookmarks
 {
+    if (!self.libraryController.libraryModel) {
+        return nil;
+    }
+
     if (!_bookmarks)
         _bookmarks = [[VLCBookmarksWindowController alloc] init];
 


=====================================
modules/gui/macosx/menus/VLCMainMenu.m
=====================================
@@ -472,6 +472,7 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
     [_videoeffects setTitle: _NS("Video Effects...")];
     [_bookmarks setTitle: _NS("Bookmarks...")];
     [_playQueue setTitle: _NS("Play Queue...")];
+
     [_detachedAudioWindow setTitle: _NS("Detached Audio Window...")];
     [_info setTitle: _NS("Media Information...")];
     [_messages setTitle: _NS("Messages...")];
@@ -891,8 +892,9 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
 
 - (void)updateLibraryPlayQueueMode
 {
+    const BOOL mlAvailable = VLCMain.sharedInstance.libraryController.libraryModel != nil;
     const BOOL libraryPlayQueueMode = _playQueueController.libraryPlayQueueMode;
-    _libraryPlayQueueMode.state = libraryPlayQueueMode ? NSOnState : NSOffState;
+    _libraryPlayQueueMode.state = libraryPlayQueueMode && mlAvailable ? NSControlStateValueOn : NSControlStateValueOff;
 }
 
 - (IBAction)goToSpecificTime:(id)sender
@@ -1916,7 +1918,10 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
     if (mi == nil) {
         return YES;
     } else if (mi == self.savePlayqueueToLibrary) {
-        return _playQueueController.playQueueModel.numberOfPlayQueueItems > 0;
+        return VLCMain.sharedInstance.libraryController.libraryModel != nil &&
+               _playQueueController.playQueueModel.numberOfPlayQueueItems > 0;
+    } else if (mi == self.bookmarks || mi == self.libraryPlayQueueMode) {
+        return VLCMain.sharedInstance.libraryController.libraryModel != nil;
     } else if (mi == self.play) {
         return _playerController.playerState == VLC_PLAYER_STATE_PLAYING
             ? _playerController.currentMedia != nil && _playerController.pausable
@@ -1988,6 +1993,10 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
         return _playerController.videoTracks.count > 0;
     } else if (mi == self.voutMenuSubtitlestrack) {
         return _playerController.subtitleTracks.count > 0;
+    } else if (mi == self.libraryPlayQueueMode ||
+               mi == self.bookmarks ||
+               mi == self.savePlayqueueToLibrary) {
+        return VLCMain.sharedInstance.libraryController.libraryModel != nil;
     } else {
         NSMenuItem * const parent = mi.parentItem;
         if (parent == self.subtitle_textcolor || mi == self.subtitle_textcolor ||


=====================================
modules/gui/macosx/preferences/VLCSimplePrefsController.m
=====================================
@@ -314,7 +314,7 @@ create_toolbar_item(NSString *itemIdent, NSString *name, NSString *desc, NSStrin
     static NSArray<NSString *> *toolbarIdentifiers = nil;
 
     dispatch_once(&onceToken, ^{
-        if (VLCMain.sharedInstance.libraryController.libraryModel) {
+        if (VLCMain.sharedInstance.libraryController.shouldUseMediaLibrary) {
             toolbarIdentifiers = @[VLCIntfSettingToolbarIdentifier,
                                    VLCAudioSettingToolbarIdentifier,
                                    VLCVideoSettingToolbarIdentifier,
@@ -352,6 +352,14 @@ create_toolbar_item(NSString *itemIdent, NSString *name, NSString *desc, NSStrin
     return [self toolbarIdentifiers];
 }
 
+- (BOOL)validateToolbarItem:(NSToolbarItem *)item
+{
+    if ([item.itemIdentifier isEqual:VLCMediaLibrarySettingToolbarIdentifier]) {
+        return VLCMain.sharedInstance.libraryController.libraryModel != nil;
+    }
+    return YES;
+}
+
 - (void)initStrings
 {
     /* audio */


=====================================
modules/gui/macosx/windows/controlsbar/VLCMainVideoViewControlsBar.m
=====================================
@@ -24,6 +24,7 @@
 
 #import "extensions/NSString+Helpers.h"
 
+#import "library/VLCLibraryController.h"
 #import "library/VLCLibraryDataTypes.h"
 
 #import "main/VLCMain.h"
@@ -111,6 +112,10 @@
     _playQueueController = VLCMain.sharedInstance.playQueueController;
     _playerController = _playQueueController.playerController;
 
+    VLCLibraryController * const libraryController = VLCMain.sharedInstance.libraryController;
+    self.bookmarksButton.hidden = !libraryController.shouldUseMediaLibrary;
+    self.bookmarksButton.enabled = libraryController.libraryModel != nil;
+
     NSNotificationCenter * const notificationCenter = NSNotificationCenter.defaultCenter;
     [notificationCenter addObserver:self
                            selector:@selector(floatOnTopChanged:)
@@ -277,6 +282,10 @@
     const BOOL currentItemIsAudio = _playerController.currentMediaIsAudioOnly;
     self.videoButton.hidden = currentItemIsAudio;
     self.subtitlesButton.hidden = currentItemIsAudio;
+
+    if (!VLCMain.sharedInstance.libraryController.shouldUseMediaLibrary) {
+        self.bookmarksButton.hidden = YES;
+    }
 }
 
 - (void)playerStateUpdated:(NSNotification *)notification



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d86f220fc6dade96c636b38a35cccd7b265ebd86...7b9ac8a3b81e33645562c0260b9c8a94e8e4a994

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d86f220fc6dade96c636b38a35cccd7b265ebd86...7b9ac8a3b81e33645562c0260b9c8a94e8e4a994
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list