Commit bf4553f1 authored by hartman's avatar hartman
Browse files

* Start of new playlist for OSX.

  - basic data retrieval implemented
  - data display not yet implemented
  - many broken outlets and even more broken actions
  - won't compile
  - if you work on this (and please do) please communicate this fact to the IRC channel and make regurlar commits to prevent that multiple people work on this (and especially the NIB).
parent 25b01191
......@@ -402,43 +402,10 @@
SUPERCLASS = NSObject;
},
{
ACTIONS = {
deleteItems = id;
disableGroup = id;
enableGroup = id;
handlePopUp = id;
playItem = id;
savePlaylist = id;
searchItem = id;
selectAll = id;
toggleItemsEnabled = id;
toggleWindow = id;
};
ACTIONS = {};
CLASS = VLCPlaylist;
LANGUAGE = ObjC;
OUTLETS = {
"o_btn_playlist" = id;
"o_ctx_menu" = id;
"o_loop_popup" = id;
"o_mi_delete" = id;
"o_mi_disableGroup" = id;
"o_mi_enableGroup" = id;
"o_mi_info" = id;
"o_mi_play" = id;
"o_mi_save_playlist" = id;
"o_mi_selectall" = id;
"o_mi_toggleItemsEnabled" = id;
"o_random_ckb" = id;
"o_search_button" = id;
"o_search_keyword" = id;
"o_status_field" = id;
"o_table_view" = id;
"o_tc_author" = id;
"o_tc_duration" = id;
"o_tc_id" = id;
"o_tc_name" = id;
"o_window" = id;
};
OUTLETS = {};
SUPERCLASS = NSObject;
},
{CLASS = VLCPlaylistView; LANGUAGE = ObjC; SUPERCLASS = NSTableView; },
......
......@@ -3,13 +3,15 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>332 421 505 517 0 0 1280 938 </string>
<string>726 239 505 517 0 0 1280 938 </string>
<key>IBEditorPositions</key>
<dict>
<key>1617</key>
<string>542 480 104 149 0 0 1024 746 </string>
<key>2197</key>
<string>9 51 596 368 0 0 1280 938 </string>
<key>29</key>
<string>41 667 419 44 0 0 1024 746 </string>
<string>58 849 419 44 0 0 1280 938 </string>
<key>915</key>
<string>54 452 185 199 0 0 1024 746 </string>
</dict>
......@@ -18,13 +20,19 @@
<key>IBLockedObjects</key>
<array>
<integer>1789</integer>
<integer>2199</integer>
<integer>2206</integer>
<integer>2208</integer>
<integer>2202</integer>
<integer>2204</integer>
<integer>2203</integer>
</array>
<key>IBOpenObjects</key>
<array>
<integer>2197</integer>
<integer>21</integer>
<integer>29</integer>
</array>
<key>IBSystem Version</key>
<string>7M34</string>
<string>7R28</string>
</dict>
</plist>
......@@ -25,7 +25,7 @@
/*****************************************************************************
* VLCPlaylistView interface
*****************************************************************************/
@interface VLCPlaylistView : NSTableView
@interface VLCPlaylistView : NSOutlineView
{
}
......@@ -36,79 +36,12 @@
*****************************************************************************/
@interface VLCPlaylist : NSObject
{
int i_moveRow;
bool b_isSortDescending;
IBOutlet id o_window;
IBOutlet id o_btn_playlist;
IBOutlet id o_table_view;
IBOutlet id o_status_field;
IBOutlet id o_tc_id;
IBOutlet id o_tc_name;
IBOutlet id o_tc_author;
IBOutlet id o_tc_duration;
IBOutlet id o_tc_sortColumn;
IBOutlet id o_ctx_menu;
IBOutlet id o_mi_save_playlist;
IBOutlet id o_mi_info;
IBOutlet id o_mi_play;
IBOutlet id o_mi_delete;
IBOutlet id o_mi_selectall;
IBOutlet id o_mi_toggleItemsEnabled;
IBOutlet id o_mi_enableGroup;
IBOutlet id o_mi_disableGroup;
IBOutlet id o_random_ckb;
IBOutlet id o_search_keyword;
IBOutlet id o_search_button;
IBOutlet id o_loop_popup;
/*For playlist info window*/
IBOutlet id o_info_window;
IBOutlet id o_uri_lbl;
IBOutlet id o_title_lbl;
IBOutlet id o_author_lbl;
IBOutlet id o_uri_txt;
IBOutlet id o_title_txt;
IBOutlet id o_author_txt;
IBOutlet id o_btn_info_ok;
IBOutlet id o_btn_info_cancel;
IBOutlet id o_tbv_info;
NSImage *o_descendingSortingImage;
NSImage *o_ascendingSortingImage;
IBOutlet id o_outline_view;
}
- (void)initStrings;
- (NSMenu *)menuForEvent:(NSEvent *)o_event;
- (IBAction)toggleWindow:(id)sender;
- (IBAction)savePlaylist:(id)sender;
- (IBAction)playItem:(id)sender;
- (IBAction)deleteItems:(id)sender;
- (IBAction)toggleItemsEnabled:(id)sender;
- (IBAction)enableGroup:(id)sender;
- (IBAction)disableGroup:(id)sender;
- (IBAction)selectAll:(id)sender;
- (IBAction)searchItem:(id)sender;
- (IBAction)handlePopUp:(id)sender;
- (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue;
- (void)updateRowSelection;
- (void)playlistUpdated;
/*For playlist info window*/
- (int)selectedPlaylistItem;
- (void)deleteGroup:(int)i_id;
- (NSMutableArray *)selectedPlaylistItemsList;
- (NSColor *)getColor:(int)i_group;
@end
......@@ -126,19 +126,15 @@
- (void)awakeFromNib
{
[o_table_view setTarget: self];
[o_table_view setDelegate: self];
[o_table_view setDataSource: self];
[o_outline_view setTarget: self];
[o_outline_view setDelegate: self];
[o_outline_view setDataSource: self];
[o_table_view setDoubleAction: @selector(playItem:)];
//[o_outline_view setDoubleAction: @selector(playItem:)];
[o_table_view registerForDraggedTypes:
[o_outline_view registerForDraggedTypes:
[NSArray arrayWithObjects: NSFilenamesPboardType, nil]];
[o_table_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
[o_window setExcludedFromWindowsMenu: TRUE];
// [o_tbv_info setDataSource: [VLCInfoDataSource init]];
[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*/
......@@ -167,6 +163,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
- (void)initStrings
{
#if 0
[o_window setTitle: _NS("Playlist")];
[o_mi_save_playlist setTitle: _NS("Save Playlist...")];
[o_mi_play setTitle: _NS("Play")];
......@@ -186,397 +183,9 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
[[o_loop_popup itemAtIndex:0] setTitle: _NS("Standard Play")];
[[o_loop_popup itemAtIndex:1] setTitle: _NS("Repeat One")];
[[o_loop_popup itemAtIndex:2] setTitle: _NS("Repeat All")];
}
- (void) tableView:(NSTableView*)o_tv
didClickTableColumn:(NSTableColumn *)o_tc
{
intf_thread_t * p_intf = VLCIntf;
playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
int max = [[o_table_view tableColumns] count];
int i;
if( p_playlist == NULL )
{
return;
}
if( o_tc_sortColumn == o_tc )
{
b_isSortDescending = !b_isSortDescending;
}
else if( o_tc == o_tc_name || o_tc == o_tc_author ||
o_tc == o_tc_id )
{
b_isSortDescending = VLC_FALSE;
[o_table_view setHighlightedTableColumn:o_tc];
o_tc_sortColumn = o_tc;
for( i=0 ; i<max ; i++ )
{
[o_table_view setIndicatorImage:nil inTableColumn:[[o_table_view tableColumns] objectAtIndex:i]];
}
}
if( o_tc_id == o_tc && !b_isSortDescending )
{
playlist_SortID( p_playlist , ORDER_NORMAL );
[o_table_view setIndicatorImage:o_ascendingSortingImage inTableColumn:o_tc];
}
else if( o_tc_name == o_tc && !b_isSortDescending )
{
playlist_SortTitle( p_playlist , ORDER_NORMAL );
[o_table_view setIndicatorImage:o_ascendingSortingImage inTableColumn:o_tc];
}
else if( o_tc_author == o_tc && !b_isSortDescending )
{
playlist_SortAuthor( p_playlist , ORDER_NORMAL );
[o_table_view setIndicatorImage:o_ascendingSortingImage inTableColumn:o_tc];
}
else if( o_tc_id == o_tc && b_isSortDescending )
{
playlist_SortID( p_playlist , ORDER_REVERSE );
[o_table_view setIndicatorImage:o_ascendingSortingImage inTableColumn:o_tc];
}
else if( o_tc_name == o_tc && b_isSortDescending )
{
playlist_SortTitle( p_playlist , ORDER_REVERSE );
[o_table_view setIndicatorImage:o_descendingSortingImage inTableColumn:o_tc];
}
else if( o_tc_author == o_tc && b_isSortDescending )
{
playlist_SortAuthor( p_playlist , ORDER_REVERSE );
[o_table_view setIndicatorImage:o_descendingSortingImage inTableColumn:o_tc];
}
vlc_object_release( p_playlist );
[self playlistUpdated];
}
- (BOOL)tableView:(NSTableView *)o_tv
shouldEditTableColumn:(NSTableColumn *)o_tc
row:(int)i_row
{
return( NO );
}
- (NSMenu *)menuForEvent:(NSEvent *)o_event
{
intf_thread_t * p_intf = VLCIntf;
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
bool b_itemstate = FALSE;
NSPoint pt;
vlc_bool_t b_rows;
vlc_bool_t b_item_sel;
pt = [o_table_view convertPoint: [o_event locationInWindow]
fromView: nil];
b_item_sel = ( [o_table_view rowAtPoint: pt] != -1 &&
[o_table_view selectedRow] != -1 );
b_rows = [o_table_view numberOfRows] != 0;
[o_mi_play setEnabled: b_item_sel];
[o_mi_delete setEnabled: b_item_sel];
[o_mi_selectall setEnabled: b_rows];
[o_mi_info setEnabled: b_item_sel];
[o_mi_toggleItemsEnabled setEnabled: b_item_sel];
[o_mi_enableGroup setEnabled: b_item_sel];
[o_mi_disableGroup setEnabled: b_item_sel];
if (p_playlist)
{
b_itemstate = ([o_table_view selectedRow] > -1) ?
p_playlist->pp_items[[o_table_view selectedRow]]->b_enabled : FALSE;
vlc_object_release(p_playlist);
}
[o_mi_toggleItemsEnabled setState: b_itemstate];
return( o_ctx_menu );
}
- (IBAction)toggleWindow:(id)sender
{
if( [o_window isVisible] )
{
[o_window orderOut:sender];
[o_btn_playlist setState:NSOffState];
}
else
{
[o_window makeKeyAndOrderFront:sender];
[o_btn_playlist setState:NSOnState];
}
}
- (IBAction)savePlaylist:(id)sender
{
intf_thread_t * p_intf = VLCIntf;
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
NSSavePanel *o_save_panel = [NSSavePanel savePanel];
NSString * o_name = [NSString stringWithFormat: @"%@.m3u", _NS("Untitled")];
[o_save_panel setTitle: _NS("Save Playlist")];
[o_save_panel setPrompt: _NS("Save")];
if( [o_save_panel runModalForDirectory: nil
file: o_name] == NSOKButton )
{
playlist_Export( p_playlist, [[o_save_panel filename] fileSystemRepresentation], "export-m3u" );
}
}
- (IBAction)playItem:(id)sender
{
intf_thread_t * p_intf = VLCIntf;
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist != NULL )
{
playlist_Goto( p_playlist, [o_table_view selectedRow] );
vlc_object_release( p_playlist );
}
}
- (IBAction)deleteItems:(id)sender
{
int i, c, i_row;
NSMutableArray *o_to_delete;
NSNumber *o_number;
intf_thread_t * p_intf = VLCIntf;
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
{
return;
}
o_to_delete = [NSMutableArray arrayWithArray:[[o_table_view selectedRowEnumerator] allObjects]];
c = (int)[o_to_delete count];
for( i = 0; i < c; i++ ) {
o_number = [o_to_delete lastObject];
i_row = [o_number intValue];
if( p_playlist->i_index == i_row && p_playlist->status.i_status )
{
playlist_Stop( p_playlist );
}
[o_to_delete removeObject: o_number];
[o_table_view deselectRow: i_row];
playlist_Delete( p_playlist, i_row );
}
vlc_object_release( p_playlist );
/* this is actually duplicity, because the intf.m manage also updates the view
* when the playlist changes. we do this on purpose, because else there is a
* delay of .5 sec or so when we delete an item */
[self playlistUpdated];
[self updateRowSelection];
}
- (IBAction)toggleItemsEnabled:(id)sender
{
#if 0
int i, c, i_row;
NSMutableArray *o_selected;
NSNumber *o_number;
intf_thread_t * p_intf = VLCIntf;
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
{
return;
}
o_selected = [NSMutableArray arrayWithArray:[[o_table_view selectedRowEnumerator] allObjects]];
c = (int)[o_selected count];
if (p_playlist->pp_items[[o_table_view selectedRow]]->b_enabled)
{
for( i = 0; i < c; i++ )
{
o_number = [o_selected lastObject];
i_row = [o_number intValue];
if( p_playlist->i_index == i_row && p_playlist->status.i_status )
{
playlist_Stop( p_playlist );
}
[o_selected removeObject: o_number];
playlist_Disable( p_playlist, i_row );
}
}
else
{
for( i = 0; i < c; i++ )
{
o_number = [o_selected lastObject];
i_row = [o_number intValue];
[o_selected removeObject: o_number];
playlist_Enable( p_playlist, i_row );
}
}
vlc_object_release( p_playlist );
[self playlistUpdated];
#endif
}
- (IBAction)enableGroup:(id)sender
{
#if 0
intf_thread_t * p_intf = VLCIntf;
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if (p_playlist)
{
playlist_EnableGroup(p_playlist,
p_playlist->pp_items[[o_table_view selectedRow]]->i_group);
vlc_object_release(p_playlist);
}
#endif
}
- (IBAction)disableGroup:(id)sender
{
#if 0
intf_thread_t * p_intf = VLCIntf;
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if (p_playlist)
{
playlist_DisableGroup(p_playlist,
p_playlist->pp_items[[o_table_view selectedRow]]->i_group);
vlc_object_release(p_playlist);
}
#endif
}
- (IBAction)selectAll:(id)sender
{
[o_table_view selectAll: nil];
}
- (IBAction)searchItem:(id)sender
{
int i_current = -1;
NSString *o_current_name;
NSString *o_current_author;
intf_thread_t * p_intf = VLCIntf;
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
{
return;
}
if( [o_table_view numberOfRows] < 1 )
{
return;
}
if( [o_table_view selectedRow] == [o_table_view numberOfRows]-1 )
{
i_current = -1;
}
else
{
i_current = [o_table_view selectedRow];
}
do
{
char *psz_temp;
i_current++;
vlc_mutex_lock( &p_playlist->object_lock );
o_current_name = [NSString stringWithUTF8String:
p_playlist->pp_items[i_current]->input.psz_name];
psz_temp = playlist_GetInfo(p_playlist, i_current ,_("General"),_("Author") );
o_current_author = [NSString stringWithUTF8String: psz_temp];
free( psz_temp);
vlc_mutex_unlock( &p_playlist->object_lock );
if( [o_current_name rangeOfString:[o_search_keyword stringValue] options:NSCaseInsensitiveSearch ].length ||
[o_current_author rangeOfString:[o_search_keyword stringValue] options:NSCaseInsensitiveSearch ].length )
{
[o_table_view selectRow: i_current byExtendingSelection: NO];
[o_table_view scrollRowToVisible: i_current];
break;
}
if( i_current == [o_table_view numberOfRows] - 1 )
{
i_current = -1;
}
}
while (i_current != [o_table_view selectedRow]);
vlc_object_release( p_playlist );
}
- (IBAction)handlePopUp:(id)sender
{
intf_thread_t * p_intf = VLCIntf;
vlc_value_t val1,val2;
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
{
return;
}
switch ([o_loop_popup indexOfSelectedItem])
{
case 1:
val1.b_bool = 0;
var_Set( p_playlist, "loop", val1 );
val1.b_bool = 1;
var_Set( p_playlist, "repeat", val1 );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
break;
case 2:
val1.b_bool = 0;
var_Set( p_playlist, "repeat", val1 );
val1.b_bool = 1;
var_Set( p_playlist, "loop", val1 );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
break;
default:
var_Get( p_playlist, "repeat", &val1 );
var_Get( p_playlist, "loop", &val2 );
if (val1.b_bool || val2.b_bool)
{
val1.b_bool = 0;
var_Set( p_playlist, "repeat", val1 );
var_Set( p_playlist, "loop", val1 );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
}
break;
}
vlc_object_release( p_playlist );
[self playlistUpdated];
}
- (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue
......@@ -670,231 +279,128 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
vlc_object_release( p_playlist );
}
- (void)playlistUpdated
{