X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fmacosx%2Fplaylist.m;h=3a265f14bed7f449f1edcbe468a2282e525db62e;hb=df1391498a5513cc50de9bc6d7895932e1454696;hp=cbae24b6b431a59ba30a0e9074280e8623c57416;hpb=be05e83bd9e714ef409e0d91b778eaead6c9ab4e;p=vlc diff --git a/modules/gui/macosx/playlist.m b/modules/gui/macosx/playlist.m index cbae24b6b4..3a265f14be 100644 --- a/modules/gui/macosx/playlist.m +++ b/modules/gui/macosx/playlist.m @@ -92,7 +92,6 @@ @end - /***************************************************************************** * VLCPlaylistCommon implementation * @@ -116,6 +115,7 @@ [o_outline_view setTarget: self]; [o_outline_view setDelegate: self]; [o_outline_view setDataSource: self]; + [o_outline_view setAllowsEmptySelection: NO]; vlc_object_release( p_playlist ); [self initStrings]; @@ -149,7 +149,7 @@ int i_return = 0; playlist_item_t *p_item = NULL; playlist_t * p_playlist = pl_Yield( VLCIntf ); - NSAssert( outlineView != o_outline_view ) + assert( outlineView == o_outline_view ); if( !item ) p_item = p_playlist->p_root_category; @@ -293,13 +293,12 @@ } else { - o_value = @"-:--:--"; + o_value = @"--:--"; } } free( psz_artist ); } - - return( o_value ); + return o_value; } @end @@ -384,12 +383,11 @@ 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: @@ -469,7 +467,7 @@ 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 @@ -477,7 +475,7 @@ 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 ); } @@ -485,33 +483,44 @@ - (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]; vlc_object_release( p_playlist ); } +- (void)outlineViewSelectionDidChange:(NSNotification *)notification +{ + // FIXME: unsafe + playlist_item_t * p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue]; + + if( p_item ) + { + /* update our info-panel to reflect the new item */ + [[[VLCMain sharedInstance] getInfo] updatePanelWithItem:p_item->p_input]; + } +} + +- (BOOL)isSelectionEmpty +{ + return [o_outline_view selectedRow] == -1; +} + - (void)updateRowSelection { int i_row; unsigned int j; + // FIXME: unsafe playlist_t *p_playlist = pl_Yield( VLCIntf ); playlist_item_t *p_item, *p_temp_item; NSMutableArray *o_array = [NSMutableArray array]; @@ -542,10 +551,11 @@ } + /* update our info-panel to reflect the new item */ + [[[VLCMain sharedInstance] getInfo] updatePanelWithItem:p_item->p_input]; + vlc_object_release( p_playlist ); - /* update our info-panel to reflect the new item */ - [[[VLCMain sharedInstance] getInfo] updatePanel]; } /* Check if p_item is a child of p_node recursively. We need to check the item @@ -730,7 +740,7 @@ p_item = NULL; } } - playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, true, p_node, p_item ); + playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, false, p_node, p_item ); } vlc_object_release( p_playlist ); } @@ -980,6 +990,7 @@ int i_item; playlist_t * p_playlist = pl_Yield( VLCIntf ); + PL_LOCK; for( i_item = 0; i_item < (int)[o_array count]; i_item++ ) { input_item_t *p_input; @@ -995,9 +1006,10 @@ /* 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, - false ); + true ); if( i_item == 0 && !b_enqueue ) { @@ -1005,14 +1017,10 @@ 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 ); } + PL_UNLOCK; + [self playlistUpdated]; vlc_object_release( p_playlist ); } @@ -1049,12 +1057,6 @@ 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]; @@ -1200,8 +1202,11 @@ pt = [o_outline_view convertPoint: [o_event locationInWindow] fromView: nil]; - b_item_sel = ( [o_outline_view rowAtPoint: pt] != -1 && - [o_outline_view selectedRow] != -1 ); + NSInteger row = [o_outline_view rowAtPoint:pt]; + if( row != -1 ) + [o_outline_view selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO]; + + b_item_sel = ( row != -1 && [o_outline_view selectedRow] != -1 ); b_rows = [o_outline_view numberOfRows] != 0; [o_mi_play setEnabled: b_item_sel]; @@ -1259,9 +1264,9 @@ 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]; @@ -1298,11 +1303,11 @@ [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 ); } @@ -1360,7 +1365,7 @@ 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 @@ -1371,16 +1376,13 @@ } 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; }