#include "controls.h"
#include "vlc_osd.h"
#include "misc.h"
+#import <vlc_interaction.h>
/*****************************************************************************
* VLCPlaylistView implementation
- (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
{
int i_return = 0;
+ playlist_item_t *p_item = NULL;
playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
if( item == nil )
{
/* root object */
- if( p_playlist->p_root_category )
- {
- i_return = p_playlist->p_root_category->i_children;
- }
+ p_item = p_playlist->p_root_category;
}
else
{
- playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
- if( p_item )
- i_return = p_item->i_children;
+ p_item = (playlist_item_t *)[item pointerValue];
}
+ if( p_item )
+ i_return = p_item->i_children;
vlc_object_release( p_playlist );
if( i_return <= 0 )
i_return = 0;
-
+NSLog( @"%d children for %s", i_return, p_item->p_input->psz_name );
return i_return;
}
/* return the child at index for the Obj-C pointer item */ /* DONE */
- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
{
- playlist_item_t *p_return = NULL;
+ playlist_item_t *p_return = NULL, *p_item = NULL;
+ NSValue *o_value;
playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
- NSValue *o_value;
if( p_playlist == NULL )
return nil;
if( item == nil )
{
/* root object */
- if( p_playlist->p_root_category )
- {
- p_return = p_playlist->p_root_category->pp_children[index];
- }
+ p_item = p_playlist->p_root_category;
}
else
{
- playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
- if( p_item && index < p_item->i_children && index >= 0 )
- p_return = p_item->pp_children[index];
+ p_item = (playlist_item_t *)[item pointerValue];
}
-
+ if( p_item && index < p_item->i_children && index >= 0 )
+ p_return = p_item->pp_children[index];
+
vlc_object_release( p_playlist );
o_value = [o_outline_dict objectForKey:[NSString stringWithFormat: @"%p", p_return]];
+ NSLog( @"%s", p_return->p_input->psz_name);
if( o_value == nil )
{
o_value = [[NSValue valueWithPointer: p_return] retain];
+ NSLog( @"error missing value" );
}
return o_value;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{
int i_return = 0;
- playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
+ playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
return NO;
}
vlc_object_release( p_playlist );
+NSLog( @"expandable" );
if( i_return <= 0 )
return NO;
else
if( item == nil || ![item isKindOfClass: [NSValue class]] ) return( @"error" );
- p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
- if( p_playlist == NULL )
- {
- return( @"error" );
- }
-
+ /* Check to see if the playlist is present */
+ p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+ if( p_playlist == NULL ) return( @"error");
+ vlc_object_release( p_playlist);
+
p_item = (playlist_item_t *)[item pointerValue];
-
if( p_item == NULL )
{
- vlc_object_release( p_playlist );
return( @"error");
}
-
+//NSLog( @"values for %p", p_item );
+
if( [[o_tc identifier] isEqualToString:@"1"] )
{
o_value = [NSString stringWithUTF8String:
o_value = [NSString stringWithCString:
p_item->p_input->psz_name];
}
- else if( [[o_tc identifier] isEqualToString:@"2"] )
+ else if( [[o_tc identifier] isEqualToString:@"2"] && p_item->p_input->p_meta &&
+ p_item->p_input->p_meta->psz_artist && *p_item->p_input->p_meta->psz_artist )
{
- char *psz_temp;
- psz_temp = vlc_input_item_GetInfo( p_item->p_input ,_("Meta-information"),_("Artist") );
-
- if( psz_temp == NULL )
- o_value = @"";
- else
- {
- o_value = [NSString stringWithUTF8String: psz_temp];
- if( o_value == NULL )
- {
- o_value = [NSString stringWithCString: psz_temp];
- }
- free( psz_temp );
- }
+ o_value = [NSString stringWithUTF8String:
+ p_item->p_input->p_meta->psz_artist];
+ if( o_value == NULL )
+ o_value = [NSString stringWithCString:
+ p_item->p_input->p_meta->psz_artist];
}
else if( [[o_tc identifier] isEqualToString:@"3"] )
{
o_value = @"-:--:--";
}
}
- vlc_object_release( p_playlist );
return( o_value );
}
@end
+/*****************************************************************************
+ * extension to NSOutlineView's interface to fix compilation warnings
+ * and let us access these 2 functions properly
+ * this uses a private Apple-API, but works fine on all current OSX releases
+ * keep checking for compatiblity with future releases though
+ *****************************************************************************/
+
+@interface NSOutlineView (UndocumentedSortImages)
++ (NSImage *)_defaultTableHeaderSortImage;
++ (NSImage *)_defaultTableHeaderReverseSortImage;
+@end
+
+
/*****************************************************************************
* VLCPlaylist implementation
*****************************************************************************/
@"VLCPlaylistItemPboardType", nil]];
[o_outline_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
-/* We need to check whether _defaultTableHeaderSortImage exists, since it
-belongs to an Apple hidden private API, and then can "disapear" at any time*/
-
- if( [[NSOutlineView class] respondsToSelector:@selector(_defaultTableHeaderSortImage)] )
- {
- o_ascendingSortingImage = [[NSOutlineView class] _defaultTableHeaderSortImage];
- }
- else
- {
- o_ascendingSortingImage = nil;
- }
-
- if( [[NSOutlineView class] respondsToSelector:@selector(_defaultTableHeaderReverseSortImage)] )
- {
- o_descendingSortingImage = [[NSOutlineView class] _defaultTableHeaderReverseSortImage];
- }
- else
- {
- o_descendingSortingImage = nil;
- }
+ /* this uses private Apple API which works fine until 10.4,
+ * but keep checking in the future!
+ * These methods are being added artificially to NSOutlineView's interface above */
+ o_ascendingSortingImage = [[NSOutlineView class] _defaultTableHeaderSortImage];
+ o_descendingSortingImage = [[NSOutlineView class] _defaultTableHeaderReverseSortImage];
o_tc_sortColumn = nil;
[NSString stringWithFormat: @"%p",
[[o_array objectAtIndex:j] pointerValue]]] ) != nil )
{
- msg_Err( p_playlist, "o_item: %p", o_item );
[o_outline_view expandItem: o_item];
}
p_item = NULL;
}
}
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, 0, p_node, p_item );
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, p_node, p_item );
}
vlc_object_release( p_playlist );
}
- (IBAction)sortNodeByAuthor:(id)sender
{
- [self sortNode: SORT_AUTHOR];
+ [self sortNode: SORT_ARTIST];
}
- (void)sortNode:(int)i_mode
{
playlist_item_t *p_item;
p_item = playlist_ItemGetByInput( p_playlist, p_input );
- playlist_Control( p_playlist, PLAYLIST_ITEMPLAY, p_item );
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, NULL, p_item );
}
else
{
{
playlist_item_t *p_item;
p_item = playlist_ItemGetByInput( p_playlist, p_input );
- playlist_Control( p_playlist, PLAYLIST_ITEMPLAY, p_item );
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, NULL, p_item );
}
else
{
}
else if( o_tc == o_tc_author )
{
- i_mode = SORT_AUTHOR;
+ i_mode = SORT_ARTIST;
}
if( b_isSortDescending )
- (IBAction)addNode:(id)sender
{
+ /* we have to create a new thread here because otherwise we would block the
+ * interface since the interaction-stuff and this code would run in the same
+ * thread */
+ [NSThread detachNewThreadSelector: @selector(addNodeThreadedly)
+ toTarget: self withObject:nil];
+ [self playlistUpdated];
+}
+
+- (void)addNodeThreadedly
+{
+ NSAutoreleasePool * ourPool = [[NSAutoreleasePool alloc] init];
+
/* simply adds a new node to the end of the playlist */
playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
+ vlc_thread_set_priority( p_playlist, VLC_THREAD_PRIORITY_LOW );
+
if( !p_playlist )
{
return;
}
- playlist_item_t * p_item = playlist_NodeCreate( p_playlist,
- _("Empty Folder"), p_playlist->p_local_category );
+ int ret_v;
+ char *psz_name = NULL;
+ playlist_item_t * p_item;
+ ret_v = intf_UserStringInput( p_playlist, _("New Node"),
+ _("Please enter a name for the new node."), &psz_name );
+ if( psz_name != NULL && psz_name != "" )
+ p_item = playlist_NodeCreate( p_playlist, psz_name,
+ p_playlist->p_local_category );
+ else
+ p_item = playlist_NodeCreate( p_playlist, _("Empty Folder"),
+ p_playlist->p_local_category );
if(! p_item )
msg_Warn( VLCIntf, "node creation failed" );
vlc_object_release( p_playlist );
- [self playlistUpdated];
+ [ourPool release];
}
@end
[o_outline_dict setObject:o_value forKey:[NSString stringWithFormat:@"%p",
[o_value pointerValue]]];
-
+NSLog( @"add item %p", [o_value pointerValue] );
return o_value;
}