Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
c6abf403
Commit
c6abf403
authored
Dec 07, 2014
by
David Fuhrmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
macosx: simplify/unify addition of new playlist items
parent
f24504e4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
70 additions
and
94 deletions
+70
-94
modules/gui/macosx/CoreInteraction.m
modules/gui/macosx/CoreInteraction.m
+1
-5
modules/gui/macosx/MainWindow.m
modules/gui/macosx/MainWindow.m
+3
-3
modules/gui/macosx/PLModel.m
modules/gui/macosx/PLModel.m
+12
-16
modules/gui/macosx/applescript.m
modules/gui/macosx/applescript.m
+1
-5
modules/gui/macosx/intf.m
modules/gui/macosx/intf.m
+1
-1
modules/gui/macosx/open.m
modules/gui/macosx/open.m
+4
-11
modules/gui/macosx/playlist.h
modules/gui/macosx/playlist.h
+14
-2
modules/gui/macosx/playlist.m
modules/gui/macosx/playlist.m
+34
-51
No files found.
modules/gui/macosx/CoreInteraction.m
View file @
c6abf403
...
...
@@ -568,7 +568,6 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
NSArray
*
o_types
=
[
NSArray
arrayWithObject
:
NSFilenamesPboardType
];
NSString
*
o_desired_type
=
[
o_paste
availableTypeFromArray
:
o_types
];
NSData
*
o_carried_data
=
[
o_paste
dataForType
:
o_desired_type
];
BOOL
b_autoplay
=
config_GetInt
(
VLCIntf
,
"macosx-autoplay"
);
if
(
o_carried_data
)
{
if
([
o_desired_type
isEqualToString
:
NSFilenamesPboardType
])
{
...
...
@@ -598,11 +597,8 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
o_array
=
[
o_array
arrayByAddingObject
:
o_dic
];
}
if
(
b_autoplay
)
[[[
VLCMain
sharedInstance
]
playlist
]
appendArray
:
o_array
atPos
:
-
1
enqueue
:
NO
];
else
[[[
VLCMain
sharedInstance
]
playlist
]
appendArray
:
o_array
atPos
:
-
1
enqueue
:
YES
];
[[[
VLCMain
sharedInstance
]
playlist
]
addPlaylistItems
:
o_array
];
return
YES
;
}
}
...
...
modules/gui/macosx/MainWindow.m
View file @
c6abf403
...
...
@@ -1196,9 +1196,9 @@ static VLCMainWindow *_o_sharedInstance = nil;
playlist_item_t
*
p_node
;
if
([[
item
identifier
]
isEqualToString
:
@"playlist"
])
p_node
=
p_playlist
->
p_
local_category
;
p_node
=
p_playlist
->
p_
playing
;
else
p_node
=
p_playlist
->
p_m
l_catego
ry
;
p_node
=
p_playlist
->
p_m
edia_libra
ry
;
if
([[
o_pasteboard
types
]
containsObject
:
NSFilenamesPboardType
])
{
NSArray
*
o_values
=
[[
o_pasteboard
propertyListForType
:
NSFilenamesPboardType
]
sortedArrayUsingSelector
:
@selector
(
caseInsensitiveCompare
:)];
...
...
@@ -1218,7 +1218,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
[
o_array
addObject
:
o_dic
];
}
[[[
VLCMain
sharedInstance
]
playlist
]
a
ppendNodeArray
:
o_array
inNode
:
p_node
atPos
:-
1
enqueue
:
YES
];
[[[
VLCMain
sharedInstance
]
playlist
]
a
ddPlaylistItems
:
o_array
withParentItemId
:
p_node
->
i_id
atPos
:-
1
startPlayback
:
NO
];
return
YES
;
}
else
if
([[
o_pasteboard
types
]
containsObject
:
@"VLCPlaylistItemPboardType"
])
{
...
...
modules/gui/macosx/PLModel.m
View file @
c6abf403
...
...
@@ -21,9 +21,10 @@
#import "PLModel.h"
#import "misc.h"
#import "misc.h"
/* VLCByteCountFormatter */
#import "playlist.h"
#import "StringUtility.h"
#include <vlc_playlist.h>
#include <vlc_input_item.h>
...
...
@@ -447,14 +448,16 @@
{
NSPasteboard
*
o_pasteboard
=
[
info
draggingPasteboard
];
// this is no valid target, sanitize to top of table
if
(
index
==
NSOutlineViewDropOnItemIndex
)
index
=
0
;
if
(
targetItem
==
nil
)
{
targetItem
=
_rootItem
;
}
/* Drag & Drop inside the playlist */
if
([[
o_pasteboard
types
]
containsObject
:
VLCPLItemPasteboadType
])
{
if
(
index
==
-
1
)
// this is no valid target, sanitize to top of table
index
=
0
;
if
(
targetItem
==
nil
)
{
targetItem
=
_rootItem
;
}
NSMutableArray
*
o_filteredItems
=
[
NSMutableArray
arrayWithArray
:
_draggedItems
];
const
NSUInteger
draggedItemsCount
=
[
_draggedItems
count
];
...
...
@@ -556,20 +559,13 @@
if
(
!
psz_uri
)
continue
;
o_dic
=
[
NSDictionary
dictionaryWithObject
:[
NSString
stringWithCString
:
psz_uri
encoding
:
NSUTF8StringEncoding
]
forKey
:
@"ITEM_URL"
];
o_dic
=
[
NSDictionary
dictionaryWithObject
:
toNSStr
(
psz_uri
)
forKey
:
@"ITEM_URL"
];
free
(
psz_uri
);
[
o_array
addObject
:
o_dic
];
}
// if (item == nil)
[
_playlist
appendArray
:
o_array
atPos
:
index
enqueue
:
YES
];
// TODO support for drop on sub nodes
// else {
// assert(p_node->i_children != -1);
// [_playlist appendNodeArray:o_array inNode: p_node atPos:index enqueue:YES];
// }
[
_playlist
addPlaylistItems
:
o_array
withParentItemId
:[
targetItem
plItemId
]
atPos
:
index
startPlayback
:
NO
];
return
YES
;
}
return
NO
;
...
...
modules/gui/macosx/applescript.m
View file @
c6abf403
...
...
@@ -42,7 +42,6 @@
if
([
o_command
isEqualToString
:
@"GetURL"
]
||
[
o_command
isEqualToString
:
@"OpenURL"
])
{
if
(
o_urlString
)
{
BOOL
b_autoplay
=
config_GetInt
(
VLCIntf
,
"macosx-autoplay"
);
NSURL
*
o_url
=
[
NSURL
fileURLWithPath
:
o_urlString
];
if
(
o_url
!=
nil
)
[[
NSDocumentController
sharedDocumentController
]
noteNewRecentDocumentURL
:
o_url
];
...
...
@@ -62,10 +61,7 @@
o_dic
=
[
NSDictionary
dictionaryWithObject
:
o_urlString
forKey
:
@"ITEM_URL"
];
o_array
=
[
NSArray
arrayWithObject
:
o_dic
];
if
(
b_autoplay
)
[[[
VLCMain
sharedInstance
]
playlist
]
appendArray
:
o_array
atPos
:
-
1
enqueue
:
NO
];
else
[[[
VLCMain
sharedInstance
]
playlist
]
appendArray
:
o_array
atPos
:
-
1
enqueue
:
YES
];
[[[
VLCMain
sharedInstance
]
playlist
]
addPlaylistItems
:
o_array
];
}
}
return
nil
;
...
...
modules/gui/macosx/intf.m
View file @
c6abf403
...
...
@@ -1088,7 +1088,7 @@ static bool f_appExit = false;
[
o_result
addObject
:
o_dic
];
}
[
o_playlist
appendArray
:
o_result
atPos
:
-
1
enqueue
:
!
config_GetInt
(
VLCIntf
,
"macosx-autoplay"
)
];
[
[[
VLCMain
sharedInstance
]
playlist
]
addPlaylistItems
:
o_result
];
}
/* When user click in the Dock icon our double click in the finder */
...
...
modules/gui/macosx/open.m
View file @
c6abf403
...
...
@@ -419,8 +419,6 @@ static VLCOpen *_o_sharedMainInstance = nil;
int
i_result
;
b_autoplay
=
config_GetInt
(
VLCIntf
,
"macosx-autoplay"
);
[
o_tabview
selectTabViewItemAtIndex
:
i_type
];
[
o_file_sub_ckbox
setState
:
NSOffState
];
...
...
@@ -516,10 +514,8 @@ static VLCOpen *_o_sharedMainInstance = nil;
/* apply the options to our item(s) */
[
o_dic
setObject
:
(
NSArray
*
)[
o_options
copy
]
forKey
:
@"ITEM_OPTIONS"
];
if
(
b_autoplay
)
[[[
VLCMain
sharedInstance
]
playlist
]
appendArray
:
[
NSArray
arrayWithObject
:
o_dic
]
atPos
:
-
1
enqueue
:
NO
];
else
[[[
VLCMain
sharedInstance
]
playlist
]
appendArray
:
[
NSArray
arrayWithObject
:
o_dic
]
atPos
:
-
1
enqueue
:
YES
];
[[[
VLCMain
sharedInstance
]
playlist
]
addPlaylistItems
:[
NSArray
arrayWithObject
:
o_dic
]];
}
}
...
...
@@ -657,7 +653,6 @@ static VLCOpen *_o_sharedMainInstance = nil;
-
(
void
)
openFile
{
NSOpenPanel
*
o_open_panel
=
[
NSOpenPanel
openPanel
];
b_autoplay
=
config_GetInt
(
VLCIntf
,
"macosx-autoplay"
);
[
o_open_panel
setAllowsMultipleSelection
:
YES
];
[
o_open_panel
setCanChooseDirectories
:
YES
];
...
...
@@ -685,10 +680,8 @@ static VLCOpen *_o_sharedMainInstance = nil;
[
o_array
addObject
:
o_dic
];
}
if
(
b_autoplay
)
[[[
VLCMain
sharedInstance
]
playlist
]
appendArray
:
o_array
atPos
:
-
1
enqueue
:
NO
];
else
[[[
VLCMain
sharedInstance
]
playlist
]
appendArray
:
o_array
atPos
:
-
1
enqueue
:
YES
];
[[[
VLCMain
sharedInstance
]
playlist
]
addPlaylistItems
:
o_array
];
}
}
...
...
modules/gui/macosx/playlist.h
View file @
c6abf403
...
...
@@ -127,8 +127,20 @@
-
(
id
)
playingItem
;
-
(
NSArray
*
)
draggedItems
;
-
(
void
)
appendArray
:(
NSArray
*
)
o_array
atPos
:(
int
)
i_position
enqueue
:(
BOOL
)
b_enqueue
;
-
(
void
)
appendNodeArray
:(
NSArray
*
)
o_array
inNode
:(
playlist_item_t
*
)
p_node
atPos
:(
int
)
i_position
enqueue
:(
BOOL
)
b_enqueue
;
/**
* Simplified version to add new items at the end of the current playlist
*/
-
(
void
)
addPlaylistItems
:(
NSArray
*
)
o_array
;
/**
* Adds new items to the playlist, at specified parent node and index.
* @param o_array array of items. Each item is a Dictionary with meta info.
* @param i_plItemId parent playlist node id, -1 for default playlist
* @param i_position index for new items, -1 for appending at end
* @param b_start starts playback of first item if true
*/
-
(
void
)
addPlaylistItems
:(
NSArray
*
)
o_array
withParentItemId
:(
int
)
i_plItemId
atPos
:(
int
)
i_position
startPlayback
:(
BOOL
)
b_start
;
-
(
void
)
setColumn
:
(
NSString
*
)
o_column
state
:
(
NSInteger
)
i_state
translationDict
:(
NSDictionary
*
)
o_dict
;
-
(
void
)
continuePlaybackWhereYouLeftOff
:(
input_thread_t
*
)
p_input_thread
;
...
...
modules/gui/macosx/playlist.m
View file @
c6abf403
...
...
@@ -784,77 +784,60 @@
return
p_input
;
}
-
(
void
)
a
ppendArray
:(
NSArray
*
)
o_array
atPos
:(
int
)
i_position
enqueue
:(
BOOL
)
b_enqueue
-
(
void
)
a
ddPlaylistItems
:(
NSArray
*
)
o_array
{
playlist_t
*
p_playlist
=
pl_Get
(
VLCIntf
);
NSUInteger
count
=
[
o_array
count
];
BOOL
b_usingPlaylist
=
[[
self
model
]
currentRootType
]
==
ROOT_TYPE_PLAYLIST
;
PL_LOCK
;
for
(
NSUInteger
i_item
=
0
;
i_item
<
count
;
i_item
++
)
{
input_item_t
*
p_input
;
NSDictionary
*
o_one_item
;
int
i_plItemId
=
-
1
;
/* Get the item */
o_one_item
=
[
o_array
objectAtIndex
:
i_item
];
p_input
=
[
self
createItem
:
o_one_item
];
if
(
!
p_input
)
continue
;
// add items directly to media library if this is the current root
if
([[
self
model
]
currentRootType
]
==
ROOT_TYPE_MEDIALIBRARY
)
i_plItemId
=
[[[
self
model
]
rootItem
]
plItemId
];
/* Add the item */
int
returnValue
=
playlist_AddInput
(
p_playlist
,
p_input
,
PLAYLIST_INSERT
,
i_position
==
-
1
?
PLAYLIST_END
:
i_position
+
i_item
,
b_usingPlaylist
,
pl_Locked
);
if
(
returnValue
!=
VLC_SUCCESS
)
{
vlc_gc_decref
(
p_input
);
continue
;
}
BOOL
b_autoplay
=
var_InheritBool
(
VLCIntf
,
"macosx-autoplay"
);
if
(
i_item
==
0
&&
!
b_enqueue
)
{
playlist_item_t
*
p_item
=
playlist_ItemGetByInput
(
p_playlist
,
p_input
);
playlist_Control
(
p_playlist
,
PLAYLIST_VIEWPLAY
,
pl_Locked
,
p_item
->
p_parent
,
p_item
);
}
vlc_gc_decref
(
p_input
);
}
PL_UNLOCK
;
[
self
playlistUpdated
];
[
self
addPlaylistItems
:
o_array
withParentItemId
:
i_plItemId
atPos
:-
1
startPlayback
:
b_autoplay
];
}
-
(
void
)
a
ppendNodeArray
:(
NSArray
*
)
o_array
inNode
:(
playlist_item_t
*
)
p_node
atPos
:(
int
)
i_position
enqueue
:(
BOOL
)
b_enqueue
-
(
void
)
a
ddPlaylistItems
:(
NSArray
*
)
o_array
withParentItemId
:(
int
)
i_plItemId
atPos
:(
int
)
i_position
startPlayback
:(
BOOL
)
b_start
{
playlist_t
*
p_playlist
=
pl_Get
(
VLCIntf
);
NSUInteger
count
=
[
o_array
count
]
;
PL_LOCK
;
for
(
NSUInteger
i_item
=
0
;
i_item
<
count
;
i_item
++
)
{
input_item_t
*
p_input
;
NSDictionary
*
o_one_item
;
playlist_item_t
*
p_parent
=
NULL
;
if
(
i_plItemId
>=
0
)
p_parent
=
playlist_ItemGetById
(
p_playlist
,
i_plItemId
);
else
p_parent
=
p_playlist
->
p_playing
;
/* Get the item */
PL_LOCK
;
o_one_item
=
[
o_array
objectAtIndex
:
i_item
];
p_input
=
[
self
createItem
:
o_one_item
];
if
(
!
p_parent
)
{
PL_UNLOCK
;
return
;
}
NSUInteger
count
=
[
o_array
count
];
int
i_current_offset
=
0
;
for
(
NSUInteger
i
=
0
;
i
<
count
;
++
i
)
{
NSDictionary
*
o_current_item
=
[
o_array
objectAtIndex
:
i
];
input_item_t
*
p_input
=
[
self
createItem
:
o_current_item
];
if
(
!
p_input
)
continue
;
/* Add the item */
playlist_NodeAddInput
(
p_playlist
,
p_input
,
p_node
,
PLAYLIST_INSERT
,
i_position
==
-
1
?
PLAYLIST_END
:
i_position
+
i_item
,
pl_Locked
);
int
i_pos
=
(
i_position
==
-
1
)
?
PLAYLIST_END
:
i_position
+
i_current_offset
++
;
playlist_item_t
*
p_item
=
playlist_NodeAddInput
(
p_playlist
,
p_input
,
p_parent
,
PLAYLIST_INSERT
,
i_pos
,
pl_Locked
);
if
(
!
p_item
)
continue
;
if
(
i_item
==
0
&&
!
b_enqueue
)
{
playlist_item_t
*
p_item
;
p_item
=
playlist_ItemGetByInput
(
p_playlist
,
p_input
);
playlist_Control
(
p_playlist
,
PLAYLIST_VIEWPLAY
,
pl_Locked
,
p_node
,
p_item
);
if
(
i
==
0
&&
b_start
)
{
playlist_Control
(
p_playlist
,
PLAYLIST_VIEWPLAY
,
pl_Locked
,
p_parent
,
p_item
);
}
PL_UNLOCK
;
vlc_gc_decref
(
p_input
);
input_item_Release
(
p_input
);
}
// [self playlistUpdated]
;
PL_UNLOCK
;
}
-
(
IBAction
)
searchItem
:(
id
)
sender
{
[[
self
model
]
searchUpdate
:[
o_search_field
stringValue
]];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment