[vlc-commits] [Git][videolan/vlc][master] 13 commits: macosx: Add method in stack to get the relevant nav state for a given input node
Steve Lhomme (@robUx4)
gitlab at videolan.org
Thu Mar 13 09:27:06 UTC 2025
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
36bb4b5f by Claudio Cambra at 2025-03-13T09:13:10+00:00
macosx: Add method in stack to get the relevant nav state for a given input node
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
de4c97c7 by Claudio Cambra at 2025-03-13T09:13:10+00:00
macosx: Do not clear child nodes before calling generateChildNodesForDirectoryNode
generateChildNodesForDirectoryNode already does this
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
a0e63296 by Claudio Cambra at 2025-03-13T09:13:10+00:00
macosx: Make input node hald in nav state writeable
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
b747853a by Claudio Cambra at 2025-03-13T09:13:10+00:00
macosx: Identify all media source view path control wrecked by input item node deletion
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
e2fff8a8 by Claudio Cambra at 2025-03-13T09:13:10+00:00
macosx: When regenerating child nodes for a directory, checkfor affected nav states and fix them
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
0831cfdd by Claudio Cambra at 2025-03-13T09:13:10+00:00
macosx: Handle left-over affected nav states post-generating directory child nodes
As we re-navigate through these nodes we will re-generate their parents
and get a correctly re-linked tree with new versions of these same
orphan nodes, so this is fine
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
a0411b42 by Claudio Cambra at 2025-03-13T09:13:10+00:00
macosx: Add callback properties for when child nodes will be generated for a given input item node
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
5936df77 by Claudio Cambra at 2025-03-13T09:13:10+00:00
macosx: Remove navigation stack handling in media source
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
ba0188e9 by Claudio Cambra at 2025-03-13T09:13:10+00:00
macosx: Install navigation stack-specific handlers on media sources loaded
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
702e2b0c by Claudio Cambra at 2025-03-13T09:13:10+00:00
macosx: Fix name of state-setting method in nav stack
We do not need/do not access the library window at all here
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
543660be by Claudio Cambra at 2025-03-13T09:13:10+00:00
macosx: Simplify (and speed up) affected navigation stack state discovery
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
2772c582 by Claudio Cambra at 2025-03-13T09:13:10+00:00
macosx: Avoid creating a VLCInputNode to get MRL
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
d770c075 by Claudio Cambra at 2025-03-13T09:13:10+00:00
macosx: Remove now unused stateForNode method
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
6 changed files:
- modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewNavigationStack.h
- modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewNavigationStack.m
- modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewNavigationState.h
- modules/gui/macosx/library/media-source/VLCMediaSource.h
- modules/gui/macosx/library/media-source/VLCMediaSource.m
- modules/gui/macosx/library/media-source/VLCMediaSourceBaseDataSource.m
Changes:
=====================================
modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewNavigationStack.h
=====================================
@@ -25,7 +25,11 @@
NS_ASSUME_NONNULL_BEGIN
@class VLCLibraryWindow;
+ at class VLCMediaSource;
@class VLCMediaSourceBaseDataSource;
+ at class VLCLibraryMediaSourceViewNavigationState;
+
+typedef struct input_item_node_t input_item_node_t;
@interface VLCLibraryMediaSourceViewNavigationStack : NSObject
@@ -40,6 +44,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)appendCurrentLibraryState;
- (void)clear;
+- (void)installHandlersOnMediaSource:(VLCMediaSource *)mediaSource;
+
@end
NS_ASSUME_NONNULL_END
=====================================
modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewNavigationStack.m
=====================================
@@ -22,6 +22,8 @@
#import "VLCLibraryMediaSourceViewNavigationStack.h"
+#import "extensions/NSString+Helpers.h"
+
#import "library/VLCInputItem.h"
#import "library/VLCInputNodePathControl.h"
#import "library/VLCInputNodePathControlItem.h"
@@ -67,6 +69,8 @@
VLCLibraryMediaSourceViewNavigationCurrentStackPosition *_currentPosition;
}
+ at property (readwrite) NSMutableDictionary<NSURL *, VLCLibraryMediaSourceViewNavigationState *> *affectedPathControlStates;
+
@end
@implementation VLCLibraryMediaSourceViewNavigationStack
@@ -76,10 +80,58 @@
self = [super init];
if (self) {
_navigationStates = [[NSMutableArray alloc] init];
+ _affectedPathControlStates = NSMutableDictionary.dictionary;
}
return self;
}
+- (void)installHandlersOnMediaSource:(VLCMediaSource *)mediaSource
+{
+ mediaSource.willStartGeneratingChildNodesForNodeHandler = ^(input_item_node_t * const node) {
+ const NSInteger rootMostAffectedState = [_navigationStates indexOfObjectPassingTest:^BOOL(VLCLibraryMediaSourceViewNavigationState * const _Nonnull obj, const NSUInteger idx, BOOL * const _Nonnull stop) {
+ return obj.currentNodeDisplayed.vlcInputItemNode == node;
+ }];
+
+ if (rootMostAffectedState != NSNotFound) {
+ for (NSUInteger i = rootMostAffectedState + 1; i < _navigationStates.count; i++) {
+ VLCLibraryMediaSourceViewNavigationState * const state = _navigationStates[i];
+ NSURL * const url = [NSURL URLWithString:state.currentNodeDisplayed.inputItem.MRL];
+ [self.affectedPathControlStates setObject:state forKey:url];
+ }
+ }
+ };
+
+ mediaSource.didFinishGeneratingChildNodesForNodeHandler = ^(input_item_node_t * const node) {
+ for (size_t i = 0; i < node->i_children; i++) {
+ input_item_node_t * const childNode = node->pp_children[i];
+ NSURL * const url = [NSURL URLWithString:toNSStr(childNode->p_item->psz_uri)];
+ VLCLibraryMediaSourceViewNavigationState * const affectedState = [self.affectedPathControlStates objectForKey:url];
+ if (affectedState != nil) {
+ affectedState.currentNodeDisplayed = [[VLCInputNode alloc] initWithInputNode:childNode];
+ [self.affectedPathControlStates removeObjectForKey:url];
+ }
+ }
+
+ // Give orphan input nodes for remaining affected path control nodes
+ for (VLCLibraryMediaSourceViewNavigationState * const state in self.affectedPathControlStates.allValues) {
+ input_item_t * const urlInputItem = input_item_NewExt(state.currentNodeDisplayed.inputItem.MRL.UTF8String,
+ state.currentNodeDisplayed.inputItem.name.UTF8String,
+ 0,
+ ITEM_TYPE_DIRECTORY,
+ ITEM_LOCAL);
+ if (urlInputItem != NULL) {
+ input_item_node_t * const urlNode = input_item_node_Create(urlInputItem);
+ if (urlNode) {
+ state.currentNodeDisplayed = [[VLCInputNode alloc] initWithInputNode:urlNode];
+ }
+ input_item_Release(urlInputItem);
+ }
+ }
+
+ [self.affectedPathControlStates removeAllObjects];
+ };
+}
+
- (void)setLibraryWindow:(VLCLibraryWindow *)delegate
{
_libraryWindow = delegate;
@@ -116,7 +168,7 @@
VLCInputNodePathControlItem *nodePathItem = [[VLCInputNodePathControlItem alloc] initWithInputNode:node];
[self.libraryWindow.mediaSourcePathControl appendInputNodePathControlItem:nodePathItem];
- [self setLibraryWindowToState:_currentPosition.navigationState];
+ [self setMediaSourceViewToState:_currentPosition.navigationState];
}
- (void)backwards
@@ -131,7 +183,7 @@
[self.libraryWindow.mediaSourcePathControl removeLastInputNodePathControlItem];
- [self setLibraryWindowToState:_currentPosition.navigationState];
+ [self setMediaSourceViewToState:_currentPosition.navigationState];
}
- (void)appendCurrentLibraryState
@@ -183,12 +235,8 @@
self.libraryWindow.backwardsNavigationButton.enabled = self.backwardsAvailable;
}
-- (void)setLibraryWindowToState:(VLCLibraryMediaSourceViewNavigationState *)state
+- (void)setMediaSourceViewToState:(VLCLibraryMediaSourceViewNavigationState *)state
{
- if (self.libraryWindow == nil) {
- return;
- }
-
[self.baseDataSource setChildDataSource:state.currentMediaSource];
[self.baseDataSource.childDataSource setNodeToDisplay:state.currentNodeDisplayed];
=====================================
modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewNavigationState.h
=====================================
@@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface VLCLibraryMediaSourceViewNavigationState : NSObject
@property (readonly) VLCMediaSourceDataSource *currentMediaSource;
- at property (readonly) VLCInputNode *currentNodeDisplayed;
+ at property (readwrite) VLCInputNode *currentNodeDisplayed;
- (instancetype)initFromMediaSourceDataSource:(VLCMediaSourceDataSource *)mediaSourceDataSource;
=====================================
modules/gui/macosx/library/media-source/VLCMediaSource.h
=====================================
@@ -53,6 +53,8 @@ extern NSString *VLCMediaSourcePreparsingEnded;
@property (nonatomic, readonly) NSString *mediaSourceDescription;
@property (nonatomic, readonly) VLCInputNode *rootNode;
@property (nonatomic, readonly) enum services_discovery_category_e category;
+ at property (readwrite) void (^willStartGeneratingChildNodesForNodeHandler)(input_item_node_t *);
+ at property (readwrite) void (^didFinishGeneratingChildNodesForNodeHandler)(input_item_node_t *);
@end
=====================================
modules/gui/macosx/library/media-source/VLCMediaSource.m
=====================================
@@ -23,7 +23,6 @@
#import "VLCMediaSource.h"
#import "extensions/NSString+Helpers.h"
-
#import "library/VLCInputItem.h"
@interface VLCMediaSource ()
@@ -311,7 +310,6 @@ static const char *const myFoldersDescription = "My Folders";
input_item_node_t *vlcInputNode = inputNode.vlcInputItemNode;
NSURL *dirUrl = [NSURL URLWithString:inputNode.inputItem.MRL];
- [self clearChildNodesForNode:vlcInputNode]; // Clear existing nodes, refresh
[self generateChildNodesForDirectoryNode:vlcInputNode withUrl:dirUrl];
return;
}
@@ -418,11 +416,15 @@ static const char *const myFoldersDescription = "My Folders";
return;
}
+ if (self.willStartGeneratingChildNodesForNodeHandler) {
+ self.willStartGeneratingChildNodesForNodeHandler(directoryNode);
+ }
+
// Clear pre-existing child nodes
while (directoryNode->i_children > 0) {
- input_item_node_t * const child = directoryNode->pp_children[0];
- input_item_node_RemoveNode(directoryNode, child);
- input_item_node_Delete(child);
+ input_item_node_t * const childNode = directoryNode->pp_children[0];
+ input_item_node_RemoveNode(directoryNode, childNode);
+ input_item_node_Delete(childNode);
}
NSError *error;
@@ -485,6 +487,10 @@ static const char *const myFoldersDescription = "My Folders";
urlInputItem = NULL;
}
}
+
+ if (self.didFinishGeneratingChildNodesForNodeHandler) {
+ self.didFinishGeneratingChildNodesForNodeHandler(directoryNode);
+ }
}
- (NSString *)mediaSourceDescription
=====================================
modules/gui/macosx/library/media-source/VLCMediaSourceBaseDataSource.m
=====================================
@@ -160,6 +160,7 @@ NSString * const VLCMediaSourceBaseDataSourceNodeChanged = @"VLCMediaSourceBaseD
for (VLCMediaSource * const mediaSource in mediaSources) {
VLCInputNode * const rootNode = [mediaSource rootNode];
[mediaSource preparseInputNodeWithinTree:rootNode];
+ [self.navigationStack installHandlersOnMediaSource:mediaSource];
}
_mediaSources = mediaSources;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/68c41afa41d8d12ed08f0981d23abc1a7f26638b...d770c075e010bd1932cf02d176a65db0c1a67069
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/68c41afa41d8d12ed08f0981d23abc1a7f26638b...d770c075e010bd1932cf02d176a65db0c1a67069
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