]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/playlist.m
with skins2(Windows), solve vlc sometimes hanging (blocked in CreateWindowEx)
[vlc] / modules / gui / macosx / playlist.m
index b4d9e24cc01112fc9ead16ca911b93214803deef..393fabea0c161c0b44f096effa5e5937414d8132 100644 (file)
@@ -50,6 +50,7 @@
 #import "vlc_osd.h"
 #import "misc.h"
 #import <vlc_interface.h>
+#import <vlc_services_discovery.h>
 
 /*****************************************************************************
  * VLCPlaylistView implementation
     [o_outline_view setDelegate: self];
     [o_outline_view setDataSource: self];
     [o_outline_view setAllowsEmptySelection: NO];
+    [o_outline_view expandItem: [o_outline_view itemAtRow:0]];
 
     vlc_object_release( p_playlist );
     [self initStrings];
 @implementation VLCPlaylistCommon (NSOutlineViewDataSource)
 
 /* return the number of children for Obj-C pointer item */ /* DONE */
-- (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
+- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
 {
     int i_return = 0;
     playlist_item_t *p_item = NULL;
 }
 
 /* return the child at index for the Obj-C pointer item */ /* DONE */
-- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
+- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
 {
     playlist_item_t *p_return = NULL, *p_item = NULL;
     NSValue *o_value;
     o_tc_sortColumn = nil;
 
     char ** ppsz_name;
-    char ** ppsz_services = services_discovery_GetServicesNames( p_playlist, &ppsz_name );
+    char ** ppsz_services = vlc_sd_GetNames( &ppsz_name );
     if( !ppsz_services )
     {
         vlc_object_release( p_playlist );
     [o_mi_delete setTitle: _NS("Delete")];
     [o_mi_recursive_expand setTitle: _NS("Expand Node")];
     [o_mi_selectall setTitle: _NS("Select All")];
-    [o_mi_info setTitle: _NS("Information...")];
+    [o_mi_info setTitle: _NS("Media Information...")];
+    [o_mi_dl_cover_art setTitle: _NS("Download Cover Art")];
     [o_mi_preparse setTitle: _NS("Fetch Meta Data")];
     [o_mi_revealInFinder setTitle: _NS("Reveal in Finder")];
     [o_mm_mi_revealInFinder setTitle: _NS("Reveal in Finder")];
 
     playlist_t *p_playlist = pl_Hold( VLCIntf );
 
+    PL_LOCK;
     if( playlist_CurrentSize( p_playlist ) >= 2 )
     {
         [o_status_field setStringValue: [NSString stringWithFormat:
         else
             [o_status_field setStringValue: _NS("1 item")];
     }
+    PL_UNLOCK;
     vlc_object_release( p_playlist );
 
     [self outlineViewSelectionDidChange: nil];
 
     if( p_item )
     {
-        /* update our info-panel to reflect the new item */
-        [[[VLCMain sharedInstance] getInfo] updatePanelWithItem:p_item->p_input];
-        
         /* update the state of our Reveal-in-Finder menu items */
         NSMutableString *o_mrl;
         char *psz_uri = input_item_GetURI( p_item->p_input );
         }
         [o_mi_revealInFinder setEnabled: NO];
         [o_mm_mi_revealInFinder setEnabled: NO];
+
+        if( [[VLCMain sharedInstance] isPlaylistCollapsed] == NO )
+        {
+            /* update our info-panel to reflect the new item, if we aren't collapsed */
+            [[[VLCMain sharedInstance] getInfo] updatePanelWithItem:p_item->p_input];
+        }
     }
 }
 
     playlist_item_t *p_item, *p_temp_item;
     NSMutableArray *o_array = [NSMutableArray array];
 
+    PL_LOCK;
     p_item = playlist_CurrentPlayingItem( p_playlist );
     if( p_item == NULL )
     {
+        PL_UNLOCK;
         pl_Release( VLCIntf );
         return;
     }
 
     }
 
+    PL_UNLOCK;
     pl_Release( VLCIntf );
 }
 
         {
             if( p_item->i_children == -1 )
             {
-                playlist_PreparseEnqueue( p_playlist, p_item->p_input );
+                playlist_PreparseEnqueue( p_playlist, p_item->p_input, pl_Unlocked );
             }
             else
             {
     [self playlistUpdated];
 }
 
+- (IBAction)downloadCoverArt:(id)sender
+{
+    int i_count;
+    NSMutableArray *o_to_preparse;
+    intf_thread_t * p_intf = VLCIntf;
+    playlist_t * p_playlist = pl_Hold( p_intf );
+
+    o_to_preparse = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];
+    i_count = [o_to_preparse count];
+
+    int i, i_row;
+    NSNumber *o_number;
+    playlist_item_t *p_item = NULL;
+
+    for( i = 0; i < i_count; i++ )
+    {
+        o_number = [o_to_preparse lastObject];
+        i_row = [o_number intValue];
+        p_item = [[o_outline_view itemAtRow:i_row] pointerValue];
+        [o_to_preparse removeObject: o_number];
+        [o_outline_view deselectRow: i_row];
+
+        if( p_item && p_item->i_children == -1 )
+        {
+            playlist_AskForArtEnqueue( p_playlist, p_item->p_input, pl_Unlocked );
+        }
+    }
+    vlc_object_release( p_playlist );
+    [self playlistUpdated];
+}
+
 - (IBAction)servicesChange:(id)sender
 {
     NSMenuItem *o_mi = (NSMenuItem *)sender;
     {
         for( i = 0; i < (int)[o_options count]; i++ )
         {
-            input_item_AddOption( p_input, strdup( [[o_options objectAtIndex:i] UTF8String] ) );
+            input_item_AddOption( p_input, strdup( [[o_options objectAtIndex:i] UTF8String] ),
+                                  VLC_INPUT_OPTION_TRUSTED );
         }
     }
 
         {
             playlist_item_t *p_item = NULL;
             playlist_item_t *p_node = NULL;
-            p_item = playlist_ItemGetByInput( p_playlist, p_input, pl_Locked );
+            p_item = playlist_ItemGetByInput( p_playlist, p_input );
             if( p_item )
             {
                 if( p_item->i_children == -1 )
         if( i_item == 0 && !b_enqueue )
         {
             playlist_item_t *p_item;
-            p_item = playlist_ItemGetByInput( p_playlist, p_input, pl_Locked );
+            p_item = playlist_ItemGetByInput( p_playlist, p_input );
             playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Locked, p_node, p_item );
         }
         PL_UNLOCK;
     return( o_ctx_menu );
 }
 
-- (void)outlineView: (NSTableView*)o_tv
+- (void)outlineView: (NSOutlineView *)o_tv
                   didClickTableColumn:(NSTableColumn *)o_tc
 {
-    int i_mode = 0, i_type;
+    int i_mode, i_type = 0;
     intf_thread_t *p_intf = VLCIntf;
 
     playlist_t *p_playlist = pl_Hold( p_intf );
 
     id o_playing_item;
 
+    PL_LOCK;
     o_playing_item = [o_outline_dict objectForKey:
                 [NSString stringWithFormat:@"%p",  playlist_CurrentPlayingItem( p_playlist )]];
+    PL_UNLOCK;
 
     if( [self isItem: [o_playing_item pointerValue] inNode:
                         [item pointerValue] checkItemExistence: YES]
 
 @implementation VLCPlaylist (NSOutlineViewDataSource)
 
-- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
+- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
 {
     id o_value = [super outlineView: outlineView child: index ofItem: item];
     playlist_t *p_playlist = pl_Hold( VLCIntf );
 
+    PL_LOCK;
     if( playlist_CurrentSize( p_playlist )  >= 2 )
     {
         [o_status_field setStringValue: [NSString stringWithFormat:
             [o_status_field setStringValue: _NS("1 item")];
         }
     }
+    PL_UNLOCK;
+
     vlc_object_release( p_playlist );
 
     [o_outline_dict setObject:o_value forKey:[NSString stringWithFormat:@"%p",
     return YES;
 }
 
-- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(int)index
+- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index
 {
     playlist_t *p_playlist = pl_Hold( VLCIntf );
     NSPasteboard *o_pasteboard = [info draggingPasteboard];
     return NSDragOperationNone;
 }
 
-- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(int)index
+- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index
 {
     playlist_t * p_playlist =  pl_Hold( VLCIntf );
     NSPasteboard *o_pasteboard = [info draggingPasteboard];