[vlc-commits] [Git][videolan/vlc][master] macosx: extract media library folder management controller
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Fri Nov 6 12:19:15 UTC 2026
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
b42a44f1 by Serhii Bykov at 2026-11-06T12:41:37+01:00
macosx: extract media library folder management controller
- - - - -
6 changed files:
- extras/package/macosx/VLC.xcodeproj/project.pbxproj
- modules/gui/macosx/Makefile.am
- + modules/gui/macosx/preferences/VLCMediaLibraryFolderManagementController.h
- + modules/gui/macosx/preferences/VLCMediaLibraryFolderManagementController.m
- modules/gui/macosx/preferences/VLCSimplePrefsController.m
- po/POTFILES.in
Changes:
=====================================
extras/package/macosx/VLC.xcodeproj/project.pbxproj
=====================================
@@ -41,6 +41,7 @@
1C3113D51E508C6900D4DD76 /* VLCTextfieldPanelController.m in Sources */ = {isa = PBXBuildFile; fileRef = CC461F6D160078340022423C /* VLCTextfieldPanelController.m */; };
1C3113D71E508C6900D4DD76 /* VLCPopupPanelController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C7CB91B1D787E7600388902 /* VLCPopupPanelController.m */; };
1C3113D91E508C6900D4DD76 /* VLCSimplePrefsController.m in Sources */ = {isa = PBXBuildFile; fileRef = CCB24D5D0D54BBAE004D780C /* VLCSimplePrefsController.m */; };
+ 7A0C6F402C925000008A1D00 /* VLCMediaLibraryFolderManagementController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A0C6F422C925000008A1D00 /* VLCMediaLibraryFolderManagementController.m */; };
1C3113DD1E508C6900D4DD76 /* VLCTrackSynchronizationWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = CC707EC4137464CD0003010A /* VLCTrackSynchronizationWindowController.m */; };
1C3113DF1E508C6900D4DD76 /* VLCVideoEffectsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = CCCE366E13817E4500694F2A /* VLCVideoEffectsWindowController.m */; };
1C3113E11E508C6900D4DD76 /* VLCVoutView.m in Sources */ = {isa = PBXBuildFile; fileRef = CCCCDCA11413E1C000FE3DE1 /* VLCVoutView.m */; };
@@ -1034,6 +1035,8 @@
CCB0BB3013FAC9F40095BD0A /* CompatibilityFixes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CompatibilityFixes.h; sourceTree = "<group>"; };
CCB24D5D0D54BBAE004D780C /* VLCSimplePrefsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = VLCSimplePrefsController.m; sourceTree = "<group>"; };
CCB24D5E0D54BBAE004D780C /* VLCSimplePrefsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCSimplePrefsController.h; sourceTree = "<group>"; };
+ 7A0C6F412C925000008A1D00 /* VLCMediaLibraryFolderManagementController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCMediaLibraryFolderManagementController.h; sourceTree = "<group>"; };
+ 7A0C6F422C925000008A1D00 /* VLCMediaLibraryFolderManagementController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCMediaLibraryFolderManagementController.m; sourceTree = "<group>"; };
CCBE999E0F922C51000705F8 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = "<absolute>"; };
CCCCDCA01413E1C000FE3DE1 /* VLCVoutView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCVoutView.h; sourceTree = "<group>"; };
CCCCDCA11413E1C000FE3DE1 /* VLCVoutView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCVoutView.m; sourceTree = "<group>"; };
@@ -1428,6 +1431,8 @@
8ED6C28603E2EB1C0059A3A7 /* prefs.m */,
6B4D508E1E79781F004479B5 /* VLCHotkeyChangeWindow.h */,
6B4D508F1E79781F004479B5 /* VLCHotkeyChangeWindow.m */,
+ 7A0C6F412C925000008A1D00 /* VLCMediaLibraryFolderManagementController.h */,
+ 7A0C6F422C925000008A1D00 /* VLCMediaLibraryFolderManagementController.m */,
CCB24D5E0D54BBAE004D780C /* VLCSimplePrefsController.h */,
CCB24D5D0D54BBAE004D780C /* VLCSimplePrefsController.m */,
6B4D50911E7979CB004479B5 /* VLCSimplePrefsWindow.h */,
@@ -2645,6 +2650,7 @@
7DF0994F23E71E76007CA6EE /* NSMenu+VLCAdditions.m in Sources */,
7D445D8B22032B9200263D34 /* VLCPlayQueueTableView.m in Sources */,
1C3113D91E508C6900D4DD76 /* VLCSimplePrefsController.m in Sources */,
+ 7A0C6F402C925000008A1D00 /* VLCMediaLibraryFolderManagementController.m in Sources */,
7DFBDCC4226E445500B700A5 /* VLCMediaSourceBaseDataSource.m in Sources */,
6B2EFC601F2819F700F3C0EA /* VLCVolumeSlider.m in Sources */,
53E511282E1AD14A0048CEFC /* VLCLibraryFavoritesViewController.m in Sources */,
=====================================
modules/gui/macosx/Makefile.am
=====================================
@@ -472,6 +472,8 @@ libmacosx_plugin_la_SOURCES = \
gui/macosx/playqueue/VLCPlayQueueTableView.m \
gui/macosx/preferences/VLCHotkeyChangeWindow.h \
gui/macosx/preferences/VLCHotkeyChangeWindow.m \
+ gui/macosx/preferences/VLCMediaLibraryFolderManagementController.h \
+ gui/macosx/preferences/VLCMediaLibraryFolderManagementController.m \
gui/macosx/preferences/VLCSimplePrefsController.h \
gui/macosx/preferences/VLCSimplePrefsController.m \
gui/macosx/preferences/VLCSimplePrefsWindow.h \
=====================================
modules/gui/macosx/preferences/VLCMediaLibraryFolderManagementController.h
=====================================
@@ -0,0 +1,42 @@
+/*****************************************************************************
+ * VLCMediaLibraryFolderManagementController.h: Media Library folder settings
+ *****************************************************************************
+ * Copyright (C) 2008-2019 VLC authors and VideoLAN
+ *
+ * Authors: Felix Paul Kühne <fkuehne # videolan dot org>
+ * David Fuhrmann <dfuhrmann # 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>
+
+ at interface VLCMediaLibraryFolderManagementController : NSObject <NSTableViewDelegate, NSTableViewDataSource>
+
+ at property (readwrite, weak) NSTableView *libraryFolderTableView;
+ at property (readwrite, weak) NSTableColumn *nameTableColumn;
+ at property (readwrite, weak) NSTableColumn *pathTableColumn;
+ at property (readwrite, weak) NSTableColumn *presentTableColumn;
+ at property (readwrite, weak) NSTableColumn *bannedTableColumn;
+ at property (readwrite, weak) NSButton *removeFolderButton;
+ at property (readwrite, weak) NSButton *banFolderButton;
+ at property (readwrite, weak) NSButton *reloadFolderButton;
+
+- (IBAction)addFolder:(id)sender;
+- (IBAction)removeFolder:(id)sender;
+- (IBAction)banFolder:(id)sender;
+- (IBAction)reloadFolder:(id)sender;
+
+ at end
=====================================
modules/gui/macosx/preferences/VLCMediaLibraryFolderManagementController.m
=====================================
@@ -0,0 +1,175 @@
+/*****************************************************************************
+ * VLCMediaLibraryFolderManagementController.m: Media Library folder settings
+ *****************************************************************************
+ * Copyright (C) 2008-2019 VLC authors and VideoLAN
+ *
+ * Authors: Felix Paul Kühne <fkuehne # videolan dot org>
+ * David Fuhrmann <dfuhrmann # 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.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#import "VLCMediaLibraryFolderManagementController.h"
+
+#import "extensions/NSString+Helpers.h"
+#import "main/VLCMain.h"
+#import "library/VLCLibraryController.h"
+#import "library/VLCLibraryModel.h"
+#import "library/VLCLibraryDataTypes.h"
+
+ at interface VLCMediaLibraryFolderManagementController ()
+{
+ VLCLibraryController *_libraryController;
+ VLCLibraryModel *_libraryModel;
+ NSArray<VLCMediaLibraryEntryPoint *> *_cachedFolderList;
+}
+
+ at end
+
+ at implementation VLCMediaLibraryFolderManagementController
+
+- (instancetype)init
+{
+ self = [super init];
+ if (self) {
+ _libraryController = VLCMain.sharedInstance.libraryController;
+ _libraryModel = _libraryController.libraryModel;
+ _cachedFolderList = _libraryModel.listOfMonitoredFolders ?: @[];
+
+ NSNotificationCenter *notificationCenter = NSNotificationCenter.defaultCenter;
+ [notificationCenter addObserver:self
+ selector:@selector(listOfMonitoredFoldersUpdated:)
+ name:VLCLibraryModelListOfMonitoredFoldersUpdated
+ object:nil];
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ [NSNotificationCenter.defaultCenter removeObserver:self];
+}
+
+- (void)listOfMonitoredFoldersUpdated:(NSNotification *)aNotification
+{
+ _cachedFolderList = _libraryModel.listOfMonitoredFolders ?: @[];
+ [self.libraryFolderTableView reloadData];
+ [self updateFolderButtonState];
+}
+
+- (nullable VLCMediaLibraryEntryPoint *)selectedEntryPoint
+{
+ const NSInteger selectedRow = self.libraryFolderTableView.selectedRow;
+ if (selectedRow < 0 || (NSUInteger)selectedRow >= _cachedFolderList.count) {
+ return nil;
+ }
+ return _cachedFolderList[(NSUInteger)selectedRow];
+}
+
+- (void)updateFolderButtonState
+{
+ VLCMediaLibraryEntryPoint * const entryPoint = [self selectedEntryPoint];
+ if (entryPoint == nil) {
+ self.banFolderButton.enabled = self.removeFolderButton.enabled = self.reloadFolderButton.enabled = NO;
+ return;
+ }
+ self.banFolderButton.enabled = self.removeFolderButton.enabled = self.reloadFolderButton.enabled = YES;
+ [self.banFolderButton setTitle:entryPoint.isBanned ? _NS("Unban Folder") : _NS("Ban Folder")];
+}
+
+- (IBAction)addFolder:(id)sender
+{
+ NSOpenPanel *openPanel = [NSOpenPanel openPanel];
+ [openPanel setTitle:_NS("Add Folder")];
+ [openPanel setCanChooseFiles:NO];
+ [openPanel setCanChooseDirectories:YES];
+ [openPanel setAllowsMultipleSelection:YES];
+
+ NSModalResponse returnValue = [openPanel runModal];
+
+ if (returnValue == NSModalResponseOK) {
+ NSArray *URLs = [openPanel URLs];
+ NSUInteger count = [URLs count];
+ for (NSUInteger i = 0; i < count ; i++) {
+ NSURL *url = URLs[i];
+ [_libraryController addFolderWithFileURL:url];
+ }
+ }
+}
+
+- (IBAction)banFolder:(id)sender
+{
+ VLCMediaLibraryEntryPoint * const entryPoint = [self selectedEntryPoint];
+ if (entryPoint == nil) {
+ return;
+ }
+ if (entryPoint.isBanned) {
+ [_libraryController unbanFolderWithFileURL:[NSURL URLWithString:entryPoint.MRL]];
+ } else {
+ [_libraryController banFolderWithFileURL:[NSURL URLWithString:entryPoint.MRL]];
+ }
+}
+
+- (IBAction)removeFolder:(id)sender
+{
+ VLCMediaLibraryEntryPoint * const entryPoint = [self selectedEntryPoint];
+ if (entryPoint == nil) {
+ return;
+ }
+ [_libraryController removeFolderWithFileURL:[NSURL URLWithString:entryPoint.MRL]];
+}
+
+- (IBAction)reloadFolder:(id)sender
+{
+ VLCMediaLibraryEntryPoint * const entryPoint = [self selectedEntryPoint];
+ if (entryPoint == nil) {
+ return;
+ }
+ [_libraryController reloadFolderWithFileURL:[NSURL URLWithString:entryPoint.MRL]];
+}
+
+- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
+{
+ return _cachedFolderList.count;
+}
+
+- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
+{
+ if (row < 0 || (NSUInteger)row >= _cachedFolderList.count) {
+ return @"";
+ }
+
+ VLCMediaLibraryEntryPoint * const entryPoint = _cachedFolderList[(NSUInteger)row];
+ if (tableColumn == self.nameTableColumn) {
+ return [entryPoint.decodedMRL lastPathComponent];
+ } else if (tableColumn == self.presentTableColumn) {
+ return entryPoint.isPresent ? @"✔" : @"✘";
+ } else if (tableColumn == self.bannedTableColumn) {
+ return entryPoint.isBanned ? @"✔" : @"✘";
+ } else {
+ return entryPoint.decodedMRL;
+ }
+}
+
+- (void)tableViewSelectionDidChange:(NSNotification *)notification
+{
+ [self updateFolderButtonState];
+}
+
+ at end
=====================================
modules/gui/macosx/preferences/VLCSimplePrefsController.m
=====================================
@@ -26,6 +26,7 @@
#endif
#import "VLCSimplePrefsController.h"
+#import "VLCMediaLibraryFolderManagementController.h"
#ifdef HAVE_SPARKLE
#import <Sparkle/Sparkle.h> //for o_intf_last_updateLabel
@@ -48,8 +49,6 @@
#import "os-integration/VLCClickerManager.h"
#import "preferences/prefs.h"
#import "library/VLCLibraryController.h"
-#import "library/VLCLibraryModel.h"
-#import "library/VLCLibraryDataTypes.h"
#import "playqueue/VLCPlayQueueTableCellView.h"
#import "views/VLCPlaybackEndViewController.h"
#import "windows/video/VLCMainVideoViewController.h"
@@ -136,29 +135,6 @@ static NSString* VLCInputSettingToolbarIdentifier = @"Input Settings Item Identi
static NSString* VLCMediaLibrarySettingToolbarIdentifier = @"Media Library Settings Item Identifier";
static NSString* VLCHotkeysSettingToolbarIdentifier = @"Hotkeys Settings Item Identifier";
- at interface VLCMediaLibraryFolderManagementController : NSObject <NSTableViewDelegate, NSTableViewDataSource>
-{
- VLCLibraryController *_libraryController;
- VLCLibraryModel *_libraryModel;
- NSArray<VLCMediaLibraryEntryPoint *> *_cachedFolderList;
-}
-
- at property (readwrite, weak) NSTableView *libraryFolderTableView;
- at property (readwrite, weak) NSTableColumn *nameTableColumn;
- at property (readwrite, weak) NSTableColumn *pathTableColumn;
- at property (readwrite, weak) NSTableColumn *presentTableColumn;
- at property (readwrite, weak) NSTableColumn *bannedTableColumn;
- at property (readwrite, weak) NSButton *removeFolderButton;
- at property (readwrite, weak) NSButton *banFolderButton;
- at property (readwrite, weak) NSButton *reloadFolderButton;
-
-- (IBAction)addFolder:(id)sender;
-- (IBAction)removeFolder:(id)sender;
-- (IBAction)banFolder:(id)sender;
-- (IBAction)reloadFolder:(id)sender;
-
- at end
-
@interface VLCSimplePrefsController() <NSToolbarDelegate, NSWindowDelegate>
{
BOOL _audioSettingChanged;
@@ -1545,136 +1521,4 @@ static inline void save_string_list(intf_thread_t * __unused p_intf, id object,
}
- at end
-
- at implementation VLCMediaLibraryFolderManagementController
-
-- (instancetype)init
-{
- self = [super init];
- if (self) {
- _libraryController = VLCMain.sharedInstance.libraryController;
- _libraryModel = _libraryController.libraryModel;
- _cachedFolderList = _libraryModel.listOfMonitoredFolders ?: @[];
-
- NSNotificationCenter *notificationCenter = NSNotificationCenter.defaultCenter;
- [notificationCenter addObserver:self
- selector:@selector(listOfMonitoredFoldersUpdated:)
- name:VLCLibraryModelListOfMonitoredFoldersUpdated
- object:nil];
- }
- return self;
-}
-
-- (void)dealloc
-{
- [NSNotificationCenter.defaultCenter removeObserver:self];
-}
-
-- (void)listOfMonitoredFoldersUpdated:(NSNotification *)aNotification
-{
- _cachedFolderList = _libraryModel.listOfMonitoredFolders ?: @[];
- [self.libraryFolderTableView reloadData];
- [self updateFolderButtonState];
-}
-
-- (nullable VLCMediaLibraryEntryPoint *)selectedEntryPoint
-{
- const NSInteger selectedRow = self.libraryFolderTableView.selectedRow;
- if (selectedRow < 0 || (NSUInteger)selectedRow >= _cachedFolderList.count) {
- return nil;
- }
- return _cachedFolderList[(NSUInteger)selectedRow];
-}
-
-- (void)updateFolderButtonState
-{
- VLCMediaLibraryEntryPoint * const entryPoint = [self selectedEntryPoint];
- if (entryPoint == nil) {
- self.banFolderButton.enabled = self.removeFolderButton.enabled = self.reloadFolderButton.enabled = NO;
- return;
- }
- self.banFolderButton.enabled = self.removeFolderButton.enabled = self.reloadFolderButton.enabled = YES;
- [self.banFolderButton setTitle:entryPoint.isBanned ? _NS("Unban Folder") : _NS("Ban Folder")];
-}
-
-- (IBAction)addFolder:(id)sender
-{
- NSOpenPanel *openPanel = [NSOpenPanel openPanel];
- [openPanel setTitle:_NS("Add Folder")];
- [openPanel setCanChooseFiles:NO];
- [openPanel setCanChooseDirectories:YES];
- [openPanel setAllowsMultipleSelection:YES];
-
- NSModalResponse returnValue = [openPanel runModal];
-
- if (returnValue == NSModalResponseOK) {
- NSArray *URLs = [openPanel URLs];
- NSUInteger count = [URLs count];
- for (NSUInteger i = 0; i < count ; i++) {
- NSURL *url = URLs[i];
- [_libraryController addFolderWithFileURL:url];
- }
- }
-}
-
-- (IBAction)banFolder:(id)sender
-{
- VLCMediaLibraryEntryPoint * const entryPoint = [self selectedEntryPoint];
- if (entryPoint == nil) {
- return;
- }
- if (entryPoint.isBanned) {
- [_libraryController unbanFolderWithFileURL:[NSURL URLWithString:entryPoint.MRL]];
- } else {
- [_libraryController banFolderWithFileURL:[NSURL URLWithString:entryPoint.MRL]];
- }
-}
-
-- (IBAction)removeFolder:(id)sender
-{
- VLCMediaLibraryEntryPoint * const entryPoint = [self selectedEntryPoint];
- if (entryPoint == nil) {
- return;
- }
- [_libraryController removeFolderWithFileURL:[NSURL URLWithString:entryPoint.MRL]];
-}
-
-- (IBAction)reloadFolder:(id)sender
-{
- VLCMediaLibraryEntryPoint * const entryPoint = [self selectedEntryPoint];
- if (entryPoint == nil) {
- return;
- }
- [_libraryController reloadFolderWithFileURL:[NSURL URLWithString:entryPoint.MRL]];
-}
-
-- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
-{
- return _cachedFolderList.count;
-}
-
-- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
-{
- if (row < 0 || (NSUInteger)row >= _cachedFolderList.count) {
- return @"";
- }
-
- VLCMediaLibraryEntryPoint * const entryPoint = _cachedFolderList[(NSUInteger)row];
- if (tableColumn == self.nameTableColumn) {
- return [entryPoint.decodedMRL lastPathComponent];
- } else if (tableColumn == self.presentTableColumn) {
- return entryPoint.isPresent ? @"✔" : @"✘";
- } else if (tableColumn == self.bannedTableColumn) {
- return entryPoint.isBanned ? @"✔" : @"✘";
- } else {
- return entryPoint.decodedMRL;
- }
-}
-
-- (void)tableViewSelectionDidChange:(NSNotification *)notification
-{
- [self updateFolderButtonState];
-}
-
@end
=====================================
po/POTFILES.in
=====================================
@@ -568,6 +568,8 @@ modules/gui/macosx/playqueue/VLCPlayQueueTableView.h
modules/gui/macosx/playqueue/VLCPlayQueueTableView.m
modules/gui/macosx/preferences/VLCHotkeyChangeWindow.h
modules/gui/macosx/preferences/VLCHotkeyChangeWindow.m
+modules/gui/macosx/preferences/VLCMediaLibraryFolderManagementController.h
+modules/gui/macosx/preferences/VLCMediaLibraryFolderManagementController.m
modules/gui/macosx/preferences/VLCSimplePrefsController.h
modules/gui/macosx/preferences/VLCSimplePrefsController.m
modules/gui/macosx/preferences/VLCSimplePrefsWindow.h
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/b42a44f1f22f98544eb2532f1a03054b5ebc5739
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/b42a44f1f22f98544eb2532f1a03054b5ebc5739
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list