Browse Source

macosx: Move creation of NSPasteboardItem containing library media item data to new NSPasteboardItem extension

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
pull/162/head
Claudio Cambra 3 years ago
parent
commit
c66fd546e3
No known key found for this signature in database GPG Key ID: 37F593F3658DB492
  1. 6
      extras/package/macosx/VLC.xcodeproj/project.pbxproj
  2. 2
      modules/gui/macosx/Makefile.am
  3. 35
      modules/gui/macosx/extensions/NSPasteboardItem+VLCAdditions.h
  4. 43
      modules/gui/macosx/extensions/NSPasteboardItem+VLCAdditions.m
  5. 12
      modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m

6
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 */,

2
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 \

35
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@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
@protocol VLCMediaLibraryItemProtocol;
@interface NSPasteboardItem (VLCAdditions)
+ (instancetype)pasteboardItemWithLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem;
@end
NS_ASSUME_NONNULL_END

43
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@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"
@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;
}
@end

12
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"
@ -584,18 +585,9 @@ NSString * const VLCLibraryYearSortDescriptorKey = @"VLCLibraryYearSortDescripto
- (id<NSPasteboardWriting>)tableView:(NSTableView *)tableView pasteboardWriterForRow:(NSInteger)row
{
NSPasteboardItem * const pboardItem = [[NSPasteboardItem alloc] init];
const id<VLCMediaLibraryItemProtocol> libraryItem = [self libraryItemAtRow:row forTableView:tableView];
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;
return [NSPasteboardItem pasteboardItemWithLibraryItem:libraryItem];
}
#pragma mark - table view double click actions

Loading…
Cancel
Save