]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/playlist.m
macosx: Don't send PLAYLIST_SKIP. Fix adding item when an other is playing.
[vlc] / modules / gui / macosx / playlist.m
index 762e8d929cd063b5e17eff827697abdfc3e396f9..6fe2531aedb507dd75d45d177409ee89e2a3c175 100644 (file)
@@ -92,7 +92,6 @@
 
 @end
 
-
 /*****************************************************************************
  * VLCPlaylistCommon implementation
  *
     int i_return = 0;
     playlist_item_t *p_item = NULL;
     playlist_t * p_playlist = pl_Yield( VLCIntf );
-    if( outlineView != o_outline_view )
-    {
-        vlc_object_release( p_playlist );
-        return 0;
-    }
+    assert( outlineView == o_outline_view );
 
-    if( item == nil )
-    {
-        /* root object */
+    if( !item )
         p_item = p_playlist->p_root_category;
-    }
     else
-    {
         p_item = (playlist_item_t *)[item pointerValue];
-    }
+
     if( p_item )
         i_return = p_item->i_children;
-    vlc_object_release( p_playlist );
+
+    pl_Release( VLCIntf );
 
     return i_return > 0 ? i_return : 0;
 }
         else
         {
             char *psz_name = input_item_GetName( p_item->p_input );
-            if( psz_name != NULL )
+            if( !EMPTY_STR( psz_name ) )
             {
                 o_value = [NSString stringWithUTF8String: psz_name];
             }
             }
             else
             {
-                o_value = @"-:--:--";
+                o_value = @"--:--";
             }
         }
         free( psz_artist );
     }
-
-    return( o_value );
+    return o_value;
 }
 
 @end
         @"VLCPlaylistItemPboardType", nil]];
     [o_outline_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
 
-    /* This uses private Apple API which works fine until 10.4.
+    /* This uses private Apple API which works fine until 10.5.
      * We need to keep checking in the future!
      * These methods are being added artificially to NSOutlineView's interface above */
     o_ascendingSortingImage = [[NSOutlineView class] _defaultTableHeaderSortImage];
     for( i = 0; ppsz_services[i]; i++ )
     {
         bool  b_enabled;
-        char        *objectname;
         NSMenuItem  *o_lmi;
 
         char * name = ppsz_name[i] ? ppsz_name[i] : ppsz_services[i];
         /* Check whether to enable these menuitems */
-        b_enabled = playlist_IsServicesDiscoveryLoaded( p_playlist, objectname );
+        b_enabled = playlist_IsServicesDiscoveryLoaded( p_playlist, ppsz_services[i] );
 
         /* Create the menu entries used in the playlist menu */
         o_lmi = [[o_mi_services submenu] addItemWithTitle:
 
 - (void)playlistUpdated
 {
-    unsigned int i;
-
     /* Clear indications of any existing column sorting */
-    for( i = 0 ; i < [[o_outline_view tableColumns] count] ; i++ )
+    for( unsigned int i = 0 ; i < [[o_outline_view tableColumns] count] ; i++ )
     {
         [o_outline_view setIndicatorImage:nil inTableColumn:
                             [[o_outline_view tableColumns] objectAtIndex:i]];
     if( playlist_CurrentSize( p_playlist ) >= 2 )
     {
         [o_status_field setStringValue: [NSString stringWithFormat:
-                    _NS("%i items in the playlist"),
+                    _NS("%i items"),
                 playlist_CurrentSize( p_playlist )]];
     }
     else
         if( playlist_IsEmpty( p_playlist ) )
             [o_status_field setStringValue: _NS("No items in the playlist")];
         else
-            [o_status_field setStringValue: _NS("1 item in the playlist")];
+            [o_status_field setStringValue: _NS("1 item")];
     }
     vlc_object_release( p_playlist );
 }
 - (void)playModeUpdated
 {
     playlist_t *p_playlist = pl_Yield( VLCIntf );
-    vlc_value_t val, val2;
 
-    var_Get( p_playlist, "loop", &val2 );
-    var_Get( p_playlist, "repeat", &val );
-    if( val.b_bool == true )
-    {
+    bool loop = var_GetBool( p_playlist, "loop" );
+    bool repeat = var_GetBool( p_playlist, "repeat" );
+    if( repeat )
         [[[VLCMain sharedInstance] getControls] repeatOne];
-   }
-    else if( val2.b_bool == true )
-    {
+    else if( loop )
         [[[VLCMain sharedInstance] getControls] repeatAll];
-    }
     else
-    {
         [[[VLCMain sharedInstance] getControls] repeatOff];
-    }
 
     [[[VLCMain sharedInstance] getControls] shuffle];
 
             p_item = playlist_ItemGetByInput( p_playlist, p_input, true );
             playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, true, NULL, p_item );
         }
-        else
-        {
-            playlist_item_t *p_item;
-            p_item = playlist_ItemGetByInput( p_playlist, p_input, true );
-            playlist_Control( p_playlist, PLAYLIST_SKIP, true, p_item );
-        }
         vlc_gc_decref( p_input );
     }
     [self playlistUpdated];
             p_item = playlist_ItemGetByInput( p_playlist, p_input, true );
             playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, true, NULL, p_item );
         }
-        else
-        {
-            playlist_item_t *p_item;
-            p_item = playlist_ItemGetByInput( p_playlist, p_input, true );
-            playlist_Control( p_playlist, PLAYLIST_SKIP, true, p_item );
-        }
         vlc_gc_decref( p_input );
     }
     [self playlistUpdated];
         }
         else if( b_selected_item_met == YES &&
                     ( [o_current_name rangeOfString:[o_search_field
-                        stringValue] options:NSCaseInsensitiveSearch ].length ||
+                        stringValue] options:NSCaseInsensitiveSearch].length ||
                       [o_current_author rangeOfString:[o_search_field
-                        stringValue] options:NSCaseInsensitiveSearch ].length ) )
+                        stringValue] options:NSCaseInsensitiveSearch].length ) )
         {
             vlc_object_release( p_playlist );
             /*Adds the parent items in the result array as well, so that we can
         i_type = ORDER_NORMAL;
     }
 
-    vlc_mutex_lock( &p_playlist->object_lock );
+    vlc_object_lock( p_playlist );
     playlist_RecursiveNodeSort( p_playlist, p_playlist->p_root_category, i_mode, i_type );
-    vlc_mutex_unlock( &p_playlist->object_lock );
+    vlc_object_unlock( p_playlist );
 
     vlc_object_release( p_playlist );
     [self playlistUpdated];
                         [item pointerValue] checkItemExistence: YES]
                         || [o_playing_item isEqual: item] )
     {
-        [cell setFont: [NSFont boldSystemFontOfSize: 0]];
+        [cell setFont: [[NSFontManager sharedFontManager] convertFont:[cell font] toHaveTrait:NSBoldFontMask]];
     }
     else
     {
-        [cell setFont: [NSFont systemFontOfSize: 0]];
+        [cell setFont: [[NSFontManager sharedFontManager] convertFont:[cell font] toNotHaveTrait:NSBoldFontMask]];
     }
     vlc_object_release( p_playlist );
 }
     if( playlist_CurrentSize( p_playlist )  >= 2 )
     {
         [o_status_field setStringValue: [NSString stringWithFormat:
-                    _NS("%i items in the playlist"),
+                    _NS("%i items"),
              playlist_CurrentSize( p_playlist )]];
     }
     else
         }
         else
         {
-            [o_status_field setStringValue: _NS("1 item in the playlist")];
+            [o_status_field setStringValue: _NS("1 item")];
         }
     }
     vlc_object_release( p_playlist );
 
     [o_outline_dict setObject:o_value forKey:[NSString stringWithFormat:@"%p",
                                                     [o_value pointerValue]]];
-#ifndef NDEBUG
-    msg_Dbg( VLCIntf, "adding item %p", [o_value pointerValue] );
-#endif
     return o_value;
 
 }