[vlc-commits] [Git][videolan/vlc][master] macosx: Add menu item to add folder in browse view to media library
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Sun Sep 7 13:14:16 UTC 2025
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
e182a252 by Claudio Cambra at 2025-09-07T12:59:46+00:00
macosx: Add menu item to add folder in browse view to media library
- - - - -
1 changed file:
- modules/gui/macosx/library/VLCLibraryMenuController.m
Changes:
=====================================
modules/gui/macosx/library/VLCLibraryMenuController.m
=====================================
@@ -39,6 +39,7 @@
#import <vlc_input.h>
#import <vlc_url.h>
+#import <vlc_common.h>
@interface VLCLibraryMenuController ()
{
@@ -96,6 +97,11 @@
keyEquivalent:@""];
bookmarkItem.target = self;
+ NSMenuItem * const addToLibraryItem = [[NSMenuItem alloc] initWithTitle:_NS("Add to Media Library")
+ action:@selector(addToMediaLibrary:)
+ keyEquivalent:@""];
+ addToLibraryItem.target = self;
+
_favoriteItem = [[NSMenuItem alloc] initWithTitle:_NS("Toggle Favorite") action:@selector(toggleFavorite:) keyEquivalent:@""];
self.favoriteItem.target = self;
@@ -109,6 +115,7 @@
createPlaylistItem,
self.favoriteItem,
bookmarkItem,
+ addToLibraryItem,
revealItem,
_deleteItem,
markUnseenItem,
@@ -139,6 +146,7 @@
_folderInputItemRequiringMenuItems = [NSHashTable weakObjectsHashTable];
[_folderInputItemRequiringMenuItems addObject:bookmarkItem];
+ [_folderInputItemRequiringMenuItems addObject:addToLibraryItem];
}
- (void)menuItems:(NSHashTable<NSMenuItem*>*)menuItems
@@ -365,6 +373,36 @@
}
}
+- (void)addToMediaLibrary:(id)sender
+{
+ if (self.representedInputItems == nil || self.representedInputItems.count == 0) {
+ return;
+ }
+
+ VLCLibraryController * const libraryController = VLCMain.sharedInstance.libraryController;
+
+ for (VLCInputItem * const inputItem in self.representedInputItems) {
+ if (inputItem.inputType != ITEM_TYPE_DIRECTORY) {
+ continue;
+ }
+
+ NSString * const inputItemMRL = inputItem.MRL;
+ NSURL * const folderURL = [NSURL URLWithString:inputItemMRL];
+
+ if (folderURL == nil) {
+ msg_Warn(getIntf(), "Invalid URL for folder: %s", inputItemMRL.UTF8String);
+ continue;
+ }
+
+ const int result = [libraryController addFolderWithFileURL:folderURL];
+ if (result == VLC_SUCCESS) {
+ msg_Info(getIntf(), "Added folder to media library: %s", inputItemMRL.UTF8String);
+ } else {
+ msg_Warn(getIntf(), "Failed to add folder to media library: %s (error %d)", inputItemMRL.UTF8String, result);
+ }
+ }
+}
+
- (void)toggleBookmark:(id)sender
{
if (self.representedInputItems == nil ||
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/e182a252bd73bd58c8257059b442f7e4af742caa
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/e182a252bd73bd58c8257059b442f7e4af742caa
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