[vlc-commits] [Git][videolan/vlc][master] 6 commits: macosx: Add VLCMediaLibraryMediaItemUTI string
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sun Mar 26 16:49:54 UTC 2023
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
2a0fdfe9 by Claudio Cambra at 2023-03-26T17:06:39+02:00
macosx: Add VLCMediaLibraryMediaItemUTI string
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
07bf4ad4 by Claudio Cambra at 2023-03-26T17:06:40+02:00
macosx: Enable pasteboard writing from VLCLibraryAudioDataSource and drag-and-drop into playlist table view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
c66fd546 by Claudio Cambra at 2023-03-26T17:09:59+02:00
macosx: Move creation of NSPasteboardItem containing library media item data to new NSPasteboardItem extension
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
2ebe0f3f by Claudio Cambra at 2023-03-26T17:35:22+02:00
macosx: Add pasteboard writing enabling drag-and-drop for VLCLibraryAlbumTracksDataSource
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
3243eb9d by Claudio Cambra at 2023-03-26T17:35:39+02:00
macosx: Add pasteboardWriter for VLCLibraryAudioGroupDataSource, enabling drag and drop
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
fc701dfa by Claudio Cambra at 2023-03-26T17:46:40+02:00
macosx: Enable drag-and-drop with pasteboardWriter for VLCLibraryVideoTableViewDataSource
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
11 changed files:
- extras/package/macosx/VLC.xcodeproj/project.pbxproj
- modules/gui/macosx/Makefile.am
- + modules/gui/macosx/extensions/NSPasteboardItem+VLCAdditions.h
- + modules/gui/macosx/extensions/NSPasteboardItem+VLCAdditions.m
- modules/gui/macosx/library/VLCLibraryDataTypes.h
- modules/gui/macosx/library/VLCLibraryDataTypes.m
- modules/gui/macosx/library/audio-library/VLCLibraryAlbumTracksDataSource.m
- modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m
- modules/gui/macosx/library/audio-library/VLCLibraryAudioGroupDataSource.m
- modules/gui/macosx/library/video-library/VLCLibraryVideoTableViewDataSource.m
- modules/gui/macosx/playlist/VLCPlaylistDataSource.m
Changes:
=====================================
extras/package/macosx/VLC.xcodeproj/project.pbxproj
=====================================
@@ -109,6 +109,7 @@
53ED472B29C8FF9D00795DB1 /* VLCLibraryAlbumTracksTableViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 53ED472A29C8FF9D00795DB1 /* VLCLibraryAlbumTracksTableViewDelegate.m */; };
53ED472E29C907C200795DB1 /* VLCLibraryVideoTableViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 53ED472D29C907C200795DB1 /* VLCLibraryVideoTableViewDelegate.m */; };
53ED473629CA4F3400795DB1 /* VLCLibraryTableViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 53ED473529CA4F3400795DB1 /* VLCLibraryTableViewDelegate.m */; };
+ 53ED473C29CBC64200795DB1 /* NSPasteboardItem+VLCAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 53ED473B29CBC64200795DB1 /* NSPasteboardItem+VLCAdditions.m */; };
53F0E92D299B002300491D49 /* VLCInputNodePathControlItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 53F0E92C299B002300491D49 /* VLCInputNodePathControlItem.m */; };
53F0E930299B17DF00491D49 /* VLCInputNodePathControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 53F0E92F299B17DF00491D49 /* VLCInputNodePathControl.m */; };
6B0292E61F43256300A50082 /* VLCBottomBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B0292E51F43256300A50082 /* VLCBottomBarView.m */; };
@@ -323,6 +324,8 @@
53ED473729CAF67F00795DB1 /* VLCLibraryTableCellViewProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryTableCellViewProtocol.h; sourceTree = "<group>"; };
53ED473429CA4F3400795DB1 /* VLCLibraryTableViewDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryTableViewDelegate.h; sourceTree = "<group>"; };
53ED473529CA4F3400795DB1 /* VLCLibraryTableViewDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryTableViewDelegate.m; sourceTree = "<group>"; };
+ 53ED473A29CBC64200795DB1 /* NSPasteboardItem+VLCAdditions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSPasteboardItem+VLCAdditions.h"; sourceTree = "<group>"; };
+ 53ED473B29CBC64200795DB1 /* NSPasteboardItem+VLCAdditions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSPasteboardItem+VLCAdditions.m"; sourceTree = "<group>"; };
53F0E92B299B002300491D49 /* VLCInputNodePathControlItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCInputNodePathControlItem.h; sourceTree = "<group>"; };
53F0E92C299B002300491D49 /* VLCInputNodePathControlItem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCInputNodePathControlItem.m; sourceTree = "<group>"; };
53F0E92E299B17DF00491D49 /* VLCInputNodePathControl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCInputNodePathControl.h; sourceTree = "<group>"; };
@@ -1135,6 +1138,8 @@
7DF0994E23E71E76007CA6EE /* NSMenu+VLCAdditions.m */,
5307A6F32967859F001E0C6A /* NSImage+VLCAdditions.h */,
5307A6F42967859F001E0C6A /* NSImage+VLCAdditions.m */,
+ 53ED473A29CBC64200795DB1 /* NSPasteboardItem+VLCAdditions.h */,
+ 53ED473B29CBC64200795DB1 /* NSPasteboardItem+VLCAdditions.m */,
);
path = extensions;
sourceTree = "<group>";
@@ -1873,6 +1878,7 @@
buildActionMask = 2147483647;
files = (
1CCC88EC2078A3D500E5626F /* MainMenu.xib in Sources */,
+ 53ED473C29CBC64200795DB1 /* NSPasteboardItem+VLCAdditions.m in Sources */,
7D713D362201DC640042BEB7 /* VLCLibraryWindow.xib in Sources */,
1CCC88EE2078A3D500E5626F /* VLCStatusBarIconMainMenu.xib in Sources */,
1CCC88EF2078A3D500E5626F /* VLCFullScreenPanel.xib in Sources */,
=====================================
modules/gui/macosx/Makefile.am
=====================================
@@ -75,6 +75,8 @@ libmacosx_plugin_la_SOURCES = \
gui/macosx/extensions/NSString+Helpers.m \
gui/macosx/extensions/NSView+VLCAdditions.h \
gui/macosx/extensions/NSView+VLCAdditions.m \
+ gui/macosx/extensions/NSPasteboardItem+VLCAdditions.h \
+ gui/macosx/extensions/NSPasteboardItem+VLCAdditions.m \
gui/macosx/extensions/VLCHexNumberFormatter.h \
gui/macosx/extensions/VLCHexNumberFormatter.m \
gui/macosx/extensions/VLCPositionFormatter.h \
=====================================
modules/gui/macosx/extensions/NSPasteboardItem+VLCAdditions.h
=====================================
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * NSPasteboardItem+VLCAdditions.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2023 VLC authors and VideoLAN
+ *
+ * Authors: Claudio Cambra <developer at claudiocambra.com>
+ *
+ * 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>
+
+NS_ASSUME_NONNULL_BEGIN
+
+ at protocol VLCMediaLibraryItemProtocol;
+
+ at interface NSPasteboardItem (VLCAdditions)
+
++ (instancetype)pasteboardItemWithLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem;
+
+ at end
+
+NS_ASSUME_NONNULL_END
=====================================
modules/gui/macosx/extensions/NSPasteboardItem+VLCAdditions.m
=====================================
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * NSPasteboardItem+VLCAdditions.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2023 VLC authors and VideoLAN
+ *
+ * Authors: Claudio Cambra <developer at claudiocambra.com>
+ *
+ * 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 "NSPasteboardItem+VLCAdditions.h"
+
+#import "library/VLCLibraryDataTypes.h"
+
+ at implementation NSPasteboardItem (VLCAdditions)
+
++ (instancetype)pasteboardItemWithLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem
+{
+ NSPasteboardItem * const pboardItem = [[NSPasteboardItem alloc] init];
+ NSMutableArray * const encodedLibraryItemsArray = [NSMutableArray array];
+
+ [libraryItem iterateMediaItemsWithBlock:^(VLCMediaLibraryMediaItem * const mediaItem) {
+ [encodedLibraryItemsArray addObject:mediaItem];
+ }];
+
+ NSData * const data = [NSKeyedArchiver archivedDataWithRootObject:encodedLibraryItemsArray];
+ [pboardItem setData:data forType:VLCMediaLibraryMediaItemUTI];
+ return pboardItem;
+}
+
+ at end
=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.h
=====================================
@@ -25,7 +25,8 @@
NS_ASSUME_NONNULL_BEGIN
-extern NSString *VLCMediaLibraryMediaItemPasteboardType;
+extern NSString * const VLCMediaLibraryMediaItemPasteboardType;
+extern NSString * const VLCMediaLibraryMediaItemUTI;
@class VLCMediaLibraryMediaItem;
@class VLCMediaLibraryAlbum;
=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.m
=====================================
@@ -29,7 +29,8 @@
#import <vlc_url.h>
-NSString *VLCMediaLibraryMediaItemPasteboardType = @"VLCMediaLibraryMediaItemPasteboardType";
+NSString * const VLCMediaLibraryMediaItemPasteboardType = @"VLCMediaLibraryMediaItemPasteboardType";
+NSString * const VLCMediaLibraryMediaItemUTI = @"org.videolan.vlc.VLCMediaLibraryMediaItem";
const CGFloat VLCMediaLibrary4KWidth = 3840.;
const CGFloat VLCMediaLibrary4KHeight = 2160.;
=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAlbumTracksDataSource.m
=====================================
@@ -22,7 +22,9 @@
#import "VLCLibraryAlbumTracksDataSource.h"
+#import "extensions/NSPasteboardItem+VLCAdditions.h"
#import "library/VLCLibraryDataTypes.h"
+#import "library/audio-library/VLCLibrarySongTableCellView.h"
const CGFloat VLCLibraryTracksRowHeight = 40.;
@@ -49,6 +51,13 @@ const CGFloat VLCLibraryTracksRowHeight = 40.;
return 0;
}
+- (id<NSPasteboardWriting>)tableView:(NSTableView *)tableView pasteboardWriterForRow:(NSInteger)row
+{
+ const id<VLCMediaLibraryItemProtocol> libraryItem = [self libraryItemAtRow:row forTableView:tableView];
+
+ return [NSPasteboardItem pasteboardItemWithLibraryItem:libraryItem];
+}
+
- (id<VLCMediaLibraryItemProtocol>)libraryItemAtRow:(NSInteger)row
forTableView:(NSTableView *)tableView
{
=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m
=====================================
@@ -42,6 +42,7 @@
#import "library/audio-library/VLCLibrarySongsTableViewSongPlayingTableCellView.h"
#import "extensions/NSString+Helpers.h"
+#import "extensions/NSPasteboardItem+VLCAdditions.h"
#import "playlist/VLCPlaylistController.h"
#import "playlist/VLCPlaylistItem.h"
@@ -582,6 +583,13 @@ NSString * const VLCLibraryYearSortDescriptorKey = @"VLCLibraryYearSortDescripto
return VLC_ML_SORTING_DEFAULT;
}
+- (id<NSPasteboardWriting>)tableView:(NSTableView *)tableView pasteboardWriterForRow:(NSInteger)row
+{
+ const id<VLCMediaLibraryItemProtocol> libraryItem = [self libraryItemAtRow:row forTableView:tableView];
+
+ return [NSPasteboardItem pasteboardItemWithLibraryItem:libraryItem];
+}
+
#pragma mark - table view double click actions
- (void)groubSelectionDoubleClickAction:(id)sender
=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioGroupDataSource.m
=====================================
@@ -22,6 +22,8 @@
#import "VLCLibraryAudioGroupDataSource.h"
+#import "extensions/NSPasteboardItem+VLCAdditions.h"
+
#import "main/VLCMain.h"
#import "library/VLCLibraryDataTypes.h"
@@ -91,6 +93,13 @@ viewForSupplementaryElementOfKind:(NSCollectionViewSupplementaryElementKind)kind
return nil;
}
+- (id<NSPasteboardWriting>)tableView:(NSTableView *)tableView pasteboardWriterForRow:(NSInteger)row
+{
+ const id<VLCMediaLibraryItemProtocol> libraryItem = [self libraryItemAtRow:row forTableView:tableView];
+
+ return [NSPasteboardItem pasteboardItemWithLibraryItem:libraryItem];
+}
+
- (id<VLCMediaLibraryItemProtocol>)libraryItemAtIndexPath:(NSIndexPath *)indexPath
forCollectionView:(NSCollectionView *)collectionView
{
=====================================
modules/gui/macosx/library/video-library/VLCLibraryVideoTableViewDataSource.m
=====================================
@@ -33,7 +33,9 @@
#import "library/video-library/VLCLibraryVideoGroupDescriptor.h"
#import "main/CompatibilityFixes.h"
+
#import "extensions/NSString+Helpers.h"
+#import "extensions/NSPasteboardItem+VLCAdditions.h"
@interface VLCLibraryVideoTableViewDataSource ()
{
@@ -105,6 +107,13 @@
return 0;
}
+- (id<NSPasteboardWriting>)tableView:(NSTableView *)tableView pasteboardWriterForRow:(NSInteger)row
+{
+ const id<VLCMediaLibraryItemProtocol> libraryItem = [self libraryItemAtRow:row forTableView:tableView];
+
+ return [NSPasteboardItem pasteboardItemWithLibraryItem:libraryItem];
+}
+
- (id<VLCMediaLibraryItemProtocol>)libraryItemAtRow:(NSInteger)row
forTableView:(NSTableView *)tableView
{
=====================================
modules/gui/macosx/playlist/VLCPlaylistDataSource.m
=====================================
@@ -50,7 +50,7 @@ static NSString *VLCPlaylistCellIdentifier = @"VLCPlaylistCellIdentifier";
- (void)prepareForUse
{
- [_tableView registerForDraggedTypes:@[VLCMediaLibraryMediaItemPasteboardType, VLCPlaylistItemPasteboardType, NSFilenamesPboardType]];
+ [_tableView registerForDraggedTypes:@[VLCMediaLibraryMediaItemPasteboardType, VLCMediaLibraryMediaItemUTI, VLCPlaylistItemPasteboardType, NSFilenamesPboardType]];
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
@@ -132,6 +132,10 @@ static NSString *VLCPlaylistCellIdentifier = @"VLCPlaylistCellIdentifier";
/* check whether the receive data is a library item from the left-hand side */
NSData *data = [info.draggingPasteboard dataForType:VLCMediaLibraryMediaItemPasteboardType];
+ if (!data) {
+ data = [info.draggingPasteboard dataForType:VLCMediaLibraryMediaItemUTI];
+ }
+
if (!data) {
/* it's not, so check if it is a file handle from the Finder */
id propertyList = [info.draggingPasteboard propertyListForType:NSFilenamesPboardType];
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5423bb9b96da2a4a93f6b984b0f98296f22abdd1...fc701dfa9ab41ddbf74986a9ccadf4543171a717
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5423bb9b96da2a4a93f6b984b0f98296f22abdd1...fc701dfa9ab41ddbf74986a9ccadf4543171a717
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