#import "MainMenu.h"
#import "open.h"
#import "controls.h" // TODO: remove me
+#import "playlist.h"
#import "SideBarItem.h"
#import <vlc_playlist.h>
#import <vlc_aout_intf.h>
SideBarItem *libraryItem = [SideBarItem itemWithTitle:_NS("LIBRARY") identifier:@"library"];
SideBarItem *playlistItem = [SideBarItem itemWithTitle:_NS("Playlist") identifier:@"playlist"];
[playlistItem setIcon: [NSImage imageNamed:@"sidebar-playlist"]];
+ SideBarItem *medialibraryItem = [SideBarItem itemWithTitle:_NS("Media Library") identifier:@"medialibrary"];
+ [medialibraryItem setIcon: [NSImage imageNamed:@"sidebar-playlist"]];
SideBarItem *mycompItem = [SideBarItem itemWithTitle:_NS("MY COMPUTER") identifier:@"mycomputer"];
SideBarItem *devicesItem = [SideBarItem itemWithTitle:_NS("DEVICES") identifier:@"devices"];
SideBarItem *lanItem = [SideBarItem itemWithTitle:_NS("LOCAL NETWORK") identifier:@"localnetwork"];
{
[internetItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
if (!strncmp( *ppsz_name, "podcast", 7 ))
- [[internetItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-podcast"]];
+ [internetItems removeLastObject]; // we don't support podcasts at this point (see #6017)
+// [[internetItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-podcast"]];
else
[[internetItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
[[internetItems lastObject] setSdtype: SD_CAT_INTERNET];
+ [[internetItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String: *ppsz_longname]];
}
break;
case SD_CAT_DEVICES:
[devicesItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
[[devicesItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
[[devicesItems lastObject] setSdtype: SD_CAT_DEVICES];
+ [[devicesItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String: *ppsz_longname]];
}
break;
case SD_CAT_LAN:
[lanItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
[[lanItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-local"]];
[[lanItems lastObject] setSdtype: SD_CAT_LAN];
+ [[lanItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String: *ppsz_longname]];
}
break;
case SD_CAT_MYCOMPUTER:
[[mycompItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-pictures"]];
else
[[mycompItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
+ [[mycompItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String: *ppsz_longname]];
[[mycompItems lastObject] setSdtype: SD_CAT_MYCOMPUTER];
}
break;
free( ppsz_longnames );
free( p_categories );
- [libraryItem setChildren: [NSArray arrayWithObject: playlistItem]];
+ [libraryItem setChildren: [NSArray arrayWithObjects: playlistItem, medialibraryItem, nil]];
[o_sidebaritems addObject: libraryItem];
if ([mycompItem hasChildren])
[o_sidebaritems addObject: mycompItem];
[o_sidebaritems addObject: internetItem];
[o_sidebar_view reloadData];
- [o_sidebar_view selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:YES];
NSUInteger i_sidebaritem_count = [o_sidebaritems count];
for (NSUInteger x = 0; x < i_sidebaritem_count; x++)
[o_sidebar_view expandItem: [o_sidebaritems objectAtIndex: x] expandChildren: YES];
+ [o_sidebar_view selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO];
if( b_dark_interface )
{
[o_fspanel setSeekable: b_seekable];
PL_LOCK;
- if (p_playlist->items.i_size >= 1)
+ if ([[[VLCMain sharedInstance] playlist] currentPlaylistRoot] != p_playlist->p_local_category || p_playlist->p_local_category->i_children > 0)
[self hideDropZone];
else
[self showDropZone];
- (BOOL)sourceList:(PXSourceList*)aSourceList itemHasBadge:(id)item
{
- if ([[item identifier] isEqualToString: @"playlist"])
+ if ([[item identifier] isEqualToString: @"playlist"] || [[item identifier] isEqualToString: @"medialibrary"])
return YES;
return [item hasBadge];
- (NSInteger)sourceList:(PXSourceList*)aSourceList badgeValueForItem:(id)item
{
- if ([[item identifier] isEqualToString: @"playlist"]) {
- playlist_t * p_playlist = pl_Get( VLCIntf );
- NSInteger i_playlist_size;
+ playlist_t * p_playlist = pl_Get( VLCIntf );
+ NSInteger i_playlist_size;
+ if ([[item identifier] isEqualToString: @"playlist"])
+ {
+ PL_LOCK;
+ i_playlist_size = p_playlist->p_local_category->i_children;
+ PL_UNLOCK;
+
+ return i_playlist_size;
+ }
+ if ([[item identifier] isEqualToString: @"medialibrary"])
+ {
PL_LOCK;
- i_playlist_size = p_playlist->items.i_size;
+ i_playlist_size = p_playlist->p_ml_category->i_children;
PL_UNLOCK;
return i_playlist_size;
- (void)sourceListSelectionDidChange:(NSNotification *)notification
{
+ playlist_t * p_playlist = pl_Get( VLCIntf );
NSIndexSet *selectedIndexes = [o_sidebar_view selectedRowIndexes];
+ id item = [o_sidebar_view itemAtRow:[selectedIndexes firstIndex]];
//Set the label text to represent the new selection
- if([selectedIndexes count]==1) {
- id item = [o_sidebar_view itemAtRow:[selectedIndexes firstIndex]];
- if ([item sdtype] > -1)
+ if ([item sdtype] > -1)
+ {
+ BOOL sd_loaded = playlist_IsServicesDiscoveryLoaded( p_playlist, [[item identifier] UTF8String] );
+ if (!sd_loaded)
{
- playlist_t * p_playlist = pl_Get( VLCIntf );
- BOOL sd_loaded = playlist_IsServicesDiscoveryLoaded( p_playlist, [[item identifier] UTF8String] );
- if (!sd_loaded)
- {
- playlist_ServicesDiscoveryAdd( p_playlist, [[item identifier] UTF8String] );
- }
+ playlist_ServicesDiscoveryAdd( p_playlist, [[item identifier] UTF8String] );
}
+ }
- [o_chosen_category_lbl setStringValue:[item title]];
- }
- else {
- [o_chosen_category_lbl setStringValue:@"(none)"];
- }
+ [o_chosen_category_lbl setStringValue:[item title]];
+
+ if ([[item identifier] isEqualToString:@"playlist"])
+ {
+ [[[VLCMain sharedInstance] playlist] setPlaylistRoot:p_playlist->p_local_category];
+ }
+ else if([[item identifier] isEqualToString:@"medialibrary"])
+ {
+ [[[VLCMain sharedInstance] playlist] setPlaylistRoot:p_playlist->p_ml_category];
+ }
+ else
+ {
+ playlist_item_t * pl_item;
+ PL_LOCK;
+ pl_item = playlist_ChildSearchName( p_playlist->p_root, [[item untranslatedTitle] UTF8String] );
+ PL_UNLOCK;
+ [[[VLCMain sharedInstance] playlist] setPlaylistRoot: pl_item];
+ }
+
+ PL_LOCK;
+ if ([[[VLCMain sharedInstance] playlist] currentPlaylistRoot] != p_playlist->p_local_category || p_playlist->p_local_category->i_children > 0)
+ [self hideDropZone];
+ else
+ [self showDropZone];
+ PL_UNLOCK;
}
@end
@interface SideBarItem : NSObject {
NSString *title;
NSString *identifier;
+ NSString *untranslatedTitle;
NSImage *icon;
NSInteger badgeValue;
NSInteger sdtype;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *identifier;
+@property (nonatomic, copy) NSString *untranslatedTitle;
@property (nonatomic, retain) NSImage *icon;
@property NSInteger badgeValue;
@property NSInteger sdtype;
@implementation SideBarItem
@synthesize title;
+@synthesize untranslatedTitle;
@synthesize identifier;
@synthesize icon;
@synthesize badgeValue;
if (notification == nil)
[[NSNotificationCenter defaultCenter] postNotificationName: NSApplicationWillTerminateNotification object: nil];
- playlist_t * p_playlist = pl_Get( p_intf );;
+ playlist_t * p_playlist = pl_Get( p_intf );
int returnedValue = 0;
/* Save some interface state in configuration, at module quit */
/*****************************************************************************
* playlist.h: MacOS X interface module
*****************************************************************************
- * Copyright (C) 2002-2006 VLC authors and VideoLAN
+ * Copyright (C) 2002-2012 VLC authors and VideoLAN
* $Id$
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Derk-Jan Hartman <hartman at videolan dot org>
+ * Felix Paul Kühne <fkuehne at videolan dot org>
*
* 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
IBOutlet VLCPlaylistView* o_outline_view_other;
NSMutableDictionary *o_outline_dict;
+ playlist_item_t * p_current_root_item;
}
+- (void)setPlaylistRoot: (playlist_item_t *)root_item;
+- (playlist_item_t *)currentPlaylistRoot;
- (void)initStrings;
- (playlist_item_t *)selectedPlaylistItem;
- (NSOutlineView *)outlineView;
/*****************************************************************************
* playlist.m: MacOS X interface module
*****************************************************************************
-* Copyright (C) 2002-2009 VLC authors and VideoLAN
+* Copyright (C) 2002-2012 VLC authors and VideoLAN
* $Id$
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Derk-Jan Hartman <hartman at videola/n dot org>
* Benjamin Pracht <bigben at videolab dot org>
+ * Felix Paul Kühne <fkuehne at videolan dot org>
*
* 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
- (id)init
{
+ playlist_t * p_playlist = pl_Get( VLCIntf );
+ p_current_root_item = p_playlist->p_local_category;
+
self = [super init];
if ( self != nil )
{
}
return self;
}
+
- (void)awakeFromNib
{
playlist_t * p_playlist = pl_Get( VLCIntf );
[[o_tc_duration_other headerCell] setStringValue:_NS("Duration")];
}
+- (void)setPlaylistRoot: (playlist_item_t *)root_item
+{
+ p_current_root_item = root_item;
+ [o_outline_view reloadData];
+ [o_outline_view_other reloadData];
+}
+
+- (playlist_item_t *)currentPlaylistRoot
+{
+ return p_current_root_item;
+}
+
- (void)swapPlaylists:(id)newList
{
if(newList != o_outline_view)
@end
@implementation VLCPlaylistCommon (NSOutlineViewDataSource)
-
/* return the number of children for Obj-C pointer item */ /* DONE */
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
{
PL_LOCK;
if( !item )
- p_item = p_playlist->p_root_category;
+ {
+ p_item = p_current_root_item;
+ }
else
p_item = (playlist_item_t *)[item pointerValue];
if( item == nil )
{
/* root object */
- p_item = p_playlist->p_root_category;
+ p_item = p_current_root_item;
}
else
{
if( item == nil )
{
/* root object */
- if( p_playlist->p_root_category )
+ if( p_current_root_item )
{
- i_return = p_playlist->p_root_category->i_children;
+ i_return = p_current_root_item->i_children;
}
}
else
o_descendingSortingImage = [[NSOutlineView class] _defaultTableHeaderReverseSortImage];
o_tc_sortColumn = nil;
-
+#if 0
char ** ppsz_name;
char ** ppsz_services = vlc_sd_GetNames( VLCIntf, &ppsz_name, NULL );
if( !ppsz_services )
}
free( ppsz_services );
free( ppsz_name );
+#endif
}
- (void)searchfieldChanged:(NSNotification *)o_notification
else
/*If no item is selected, sort the whole playlist*/
{
- p_item = p_playlist->p_root_category;
+ p_item = [self currentPlaylistRoot];
}
PL_LOCK;
{
playlist_t * p_playlist = pl_Get( VLCIntf );
NSUInteger count = [o_array count];
+ BOOL b_usingPlaylist;
+ if ([self currentPlaylistRoot] == p_playlist->p_ml_category)
+ b_usingPlaylist = NO;
+ else
+ b_usingPlaylist = YES;
PL_LOCK;
for( NSUInteger i_item = 0; i_item < count; i_item++ )
/* Add the item */
/* FIXME: playlist_AddInput() can fail */
- playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT, i_position == -1 ? PLAYLIST_END : i_position + i_item, true,
+ playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT, i_position == -1 ? PLAYLIST_END : i_position + i_item, b_usingPlaylist,
pl_Locked );
vlc_gc_decref( p_input );
/*First, only search after the selected item:*
*(b_selected_item_met = NO) */
- o_result = [self subSearchItem:p_playlist->p_root_category];
+ o_result = [self subSearchItem:[self currentPlaylistRoot]];
if( o_result == NULL )
{
/* If the first search failed, search again from the beginning */
- o_result = [self subSearchItem:p_playlist->p_root_category];
+ o_result = [self subSearchItem:[self currentPlaylistRoot]];
}
if( o_result != NULL )
{
}
PL_LOCK;
- playlist_RecursiveNodeSort( p_playlist, p_playlist->p_root_category, i_mode, i_type );
+ playlist_RecursiveNodeSort( p_playlist, [self currentPlaylistRoot], i_mode, i_type );
PL_UNLOCK;
[self playlistUpdated];