Commit 699e4bb6 authored by hartman's avatar hartman
Browse files

OS X intf work

- don't use bool. it's BOOL
- use GNU style C and hungarian notation
- fix the issue with GUI crashes in playlistview
- default is now category view (for experimentation until we have a SD menu)
- experiment with NSViews to fix the 'drawer' issue (not working though)
parent 327dee53
......@@ -125,6 +125,7 @@
"o_btn_prev" = id;
"o_btn_rewind" = id;
"o_btn_stop" = id;
"o_clip_view" = id;
"o_controls" = id;
"o_dmi_mute" = id;
"o_dmi_next" = id;
......
......@@ -9,9 +9,9 @@
<key>1617</key>
<string>542 480 104 149 0 0 1024 746 </string>
<key>2197</key>
<string>91 300 596 367 0 0 1024 746 </string>
<string>195 211 596 367 0 0 1280 938 </string>
<key>29</key>
<string>163 439 419 44 0 0 800 578 </string>
<string>132 749 419 44 0 0 1280 938 </string>
<key>915</key>
<string>731 416 165 180 0 0 1024 746 </string>
</dict>
......@@ -22,11 +22,6 @@
<integer>2203</integer>
<integer>2208</integer>
<integer>2206</integer>
<integer>2199</integer>
</array>
<key>IBOpenObjects</key>
<array>
<integer>29</integer>
</array>
<key>IBSystem Version</key>
<string>7S215</string>
......
......@@ -87,6 +87,7 @@ struct intf_sys_t
BOOL nib_open_loaded; /* reference to the open-nib */
IBOutlet id o_window; /* main window */
IBOutlet id o_clip_view; /* playlist clipview */
IBOutlet id o_scrollfield; /* info field */
IBOutlet id o_timefield; /* time field */
IBOutlet id o_timeslider; /* time slider */
......@@ -232,6 +233,10 @@ struct intf_sys_t
IBOutlet id o_dmi_next;
IBOutlet id o_dmi_previous;
IBOutlet id o_dmi_mute;
/* stupid outline views .... */
NSRect rect_remember;
NSView *o_document_view;
}
+ (VLCMain *)sharedInstance;
......
......@@ -377,6 +377,7 @@ static VLCMain *_o_sharedMainInstance = nil;
[self setSubmenusEnabled: FALSE];
[self manageVolumeSlider];
[o_window setDelegate: self];
p_playlist = (playlist_t *) vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
......@@ -1437,6 +1438,33 @@ static VLCMain *_o_sharedMainInstance = nil;
}
}
- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)proposedFrameSize
{
if( proposedFrameSize.height <= 200 )
{
if( [sender frame].size.height > 200 )
{
//rect_remember = [[o_playlist playlistView] frame];
o_document_view = [o_clip_view documentView];
[o_document_view retain];
[o_clip_view setDocumentView: NULL];
}
return NSMakeSize( proposedFrameSize.width, 95 );
}
else
{
if( [sender frame].size.height <= 200 )
{
[o_clip_view setDocumentView: o_document_view];
[o_document_view release];
[o_document_view setFrameSize: NSMakeSize( proposedFrameSize.width - 22, proposedFrameSize.height - 120 )];
//[[o_playlist playlistView] setFrame: rect_remember];
}
return proposedFrameSize;
}
return proposedFrameSize;
}
@end
@implementation VLCMain (NSMenuValidation)
......
......@@ -60,18 +60,20 @@
NSImage *o_descendingSortingImage;
NSImage *o_ascendingSortingImage;
NSMutableDictionary * o_outline_dict;
NSMutableDictionary *o_outline_dict;
bool b_selected_item_met;
bool b_isSortDescending;
BOOL b_selected_item_met;
BOOL b_isSortDescending;
int i_current_view;
id o_tc_sortColumn;
}
- (IBAction)handlePopUp:(id)sender;
- (IBAction)searchItem:(id)sender;
- (void)initStrings;
- (NSMenu *)menuForEvent:(NSEvent *)o_event;
- (NSOutlineView *)playlistView;
- (IBAction)handlePopUp:(id)sender;
- (IBAction)searchItem:(id)sender;
- (void)updateTogglePlaylistState;
- (void)playlistUpdated;
......
......@@ -35,7 +35,6 @@
*/
/*****************************************************************************
* Preamble
*****************************************************************************/
......@@ -99,8 +98,9 @@
- (id)init
{
self = [super init];
if ( self !=nil )
if ( self != nil )
{
o_outline_dict = [[NSMutableDictionary alloc] init];
//i_moveRow = -1;
}
return self;
......@@ -108,6 +108,10 @@
- (void)awakeFromNib
{
playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
i_current_view = VIEW_CATEGORY;
playlist_ViewUpdate( p_playlist, i_current_view );
[o_outline_view setTarget: self];
[o_outline_view setDelegate: self];
[o_outline_view setDataSource: self];
......@@ -139,7 +143,6 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
o_descendingSortingImage = nil;
}
o_outline_dict = [[NSMutableDictionary alloc] init];
o_tc_sortColumn = nil;
[self initStrings];
......@@ -171,6 +174,11 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
[[o_loop_popup itemAtIndex:2] setTitle: _NS("Repeat All")];
}
- (NSOutlineView *)playlistView
{
return o_outline_view;
}
- (IBAction)toggleWindow:(id)sender
{
NSRect o_rect;
......@@ -242,14 +250,16 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
[o_outline_view setHighlightedTableColumn:nil];
o_tc_sortColumn = nil;
[o_outline_dict removeAllObjects];
// TODO Find a way to keep the dict size to a minimum
//[o_outline_dict removeAllObjects];
[o_outline_view reloadData];
}
- (void)updateTogglePlaylistState
{
if ([o_controller getSizeWithPlaylist].height ==
[o_controller minSize].height)
if( [o_controller getSizeWithPlaylist].height ==
[o_controller minSize].height )
{
[o_btn_playlist setState: NO];
}
......@@ -261,25 +271,26 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
- (void)updateRowSelection
{
playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
playlist_item_t * p_item, * p_temp_item;
NSMutableArray * o_array = [NSMutableArray array];
int i,i_row;
unsigned int j;
playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
playlist_item_t *p_item, *p_temp_item;
NSMutableArray *o_array = [NSMutableArray array];
if (p_playlist == NULL)
if( p_playlist == NULL )
return;
p_item = p_playlist->status.p_item;
p_temp_item = p_item;
while (p_temp_item->i_parents > 0)
while( p_temp_item->i_parents > 0 )
{
[o_array insertObject: [NSValue valueWithPointer: p_temp_item] atIndex: 0];
for (i = 0 ; i < p_temp_item->i_parents ; i++)
{
if (p_temp_item->pp_parents[i]->i_view == VIEW_SIMPLE)
if( p_temp_item->pp_parents[i]->i_view == i_current_view )
{
p_temp_item = p_temp_item->pp_parents[i]->p_parent;
break;
......@@ -304,27 +315,28 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
vlc_object_release(p_playlist);
}
- (bool)isItem:(playlist_item_t *)p_item inNode:(playlist_item_t *)p_node
- (BOOL)isItem: (playlist_item_t *)p_item inNode: (playlist_item_t *)p_node
{
playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
playlist_item_t * p_temp_item = p_item;
playlist_item_t *p_temp_item = p_item;
if ( p_playlist == NULL )
if( p_playlist == NULL )
{
return NO;
}
while ( p_temp_item->i_parents > 0 )
while( p_temp_item->i_parents > 0 )
{
int i;
for (i = 0; i < p_temp_item->i_parents ; i++)
for( i = 0; i < p_temp_item->i_parents ; i++ )
{
if (p_temp_item->pp_parents[i]->i_view == VIEW_SIMPLE)
if( p_temp_item->pp_parents[i]->i_view == i_current_view )
{
if (p_temp_item->pp_parents[i]->p_parent == p_node)
if( p_temp_item->pp_parents[i]->p_parent == p_node )
{
vlc_object_release(p_playlist);
vlc_object_release( p_playlist );
return YES;
}
else
......@@ -336,11 +348,12 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
}
}
vlc_object_release(p_playlist);
vlc_object_release( p_playlist );
return NO;
}
/* When called retrieves the selected outlineview row and plays that node or item */
- (IBAction)playItem:(id)sender
{
intf_thread_t * p_intf = VLCIntf;
......@@ -357,11 +370,11 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
if( p_item )
{
if (p_item->i_children == -1)
if( p_item->i_children == -1 )
{
for (i = 0 ; i < p_item->i_parents ; i++)
for( i = 0 ; i < p_item->i_parents ; i++ )
{
if (p_item->pp_parents[i]->i_view == VIEW_SIMPLE)
if( p_item->pp_parents[i]->i_view == i_current_view )
{
p_node = p_item->pp_parents[i]->p_parent;
}
......@@ -370,8 +383,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
else
{
p_node = p_item;
if (p_node->pp_children[0]->i_children == -1 &&
p_node->i_children > 0)
if( p_node->i_children > 0 && p_node->pp_children[0]->i_children == -1 )
{
p_item = p_node->pp_children[0];
}
......@@ -381,11 +393,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
}
}
// p_view = playlist_ViewFind( p_playlist, VIEW_SIMPLE );
playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VIEW_SIMPLE, p_node, p_item );
// playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VIEW_SIMPLE, p_view ? p_view->p_root : NULL, p_item );
playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, i_current_view, p_node, p_item );
}
vlc_object_release( p_playlist );
}
......@@ -398,7 +406,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
- (IBAction)deleteItem:(id)sender
{
int i, c, i_row;
int i, i_count, i_row;
NSMutableArray *o_to_delete;
NSNumber *o_number;
......@@ -413,39 +421,41 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
return;
}
o_to_delete = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];
c = [o_to_delete count];
i_count = [o_to_delete count];
for( i = 0; i < c; i++ ) {
for( i = 0; i < i_count; i++ )
{
playlist_item_t * p_item;
o_number = [o_to_delete lastObject];
i_row = [o_number intValue];
[o_to_delete removeObject: o_number];
[o_outline_view deselectRow: i_row];
p_item = (playlist_item_t *)[[o_outline_view itemAtRow: i_row]pointerValue];
if (p_item->i_children > -1)
p_item = (playlist_item_t *)[[o_outline_view itemAtRow: i_row] pointerValue];
if( p_item->i_children > -1 ) //is a node and not an item
{
if (p_playlist->status.i_status)
if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
[self isItem: p_playlist->status.p_item inNode: p_item] == YES )
{
if ([self isItem:p_playlist->status.p_item inNode: p_item]
== YES && p_playlist->status.i_status)
{
playlist_Stop( p_playlist );
}
// if current item is in selected node and is playing then stop playlist
playlist_Stop( p_playlist );
}
playlist_NodeDelete( p_playlist, p_item, VLC_TRUE);
}
else
{
if( p_playlist->status.p_item == [[o_outline_view itemAtRow: i_row]
pointerValue] && p_playlist->status.i_status )
if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
p_playlist->status.p_item == [[o_outline_view itemAtRow: i_row] pointerValue] )
{
playlist_Stop( p_playlist );
}
playlist_LockDelete( p_playlist, p_item->input.i_id );
}
[self playlistUpdated];
}
[self playlistUpdated];
vlc_object_release( p_playlist );
}
- (IBAction)sortNodeByName:(id)sender
......@@ -469,7 +479,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
return;
}
if ([o_outline_view selectedRow] > -1)
if( [o_outline_view selectedRow] > -1 )
{
p_item = [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
pointerValue];
......@@ -477,33 +487,33 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
else
/*If no item is selected, sort the whole playlist*/
{
playlist_view_t * p_view = playlist_ViewFind( p_playlist, VIEW_SIMPLE );
playlist_view_t * p_view = playlist_ViewFind( p_playlist, i_current_view );
p_item = p_view->p_root;
}
if (p_item->i_children > -1)
if( p_item->i_children > -1 ) // the item is a node
{
vlc_mutex_lock(&p_playlist->object_lock );
vlc_mutex_lock( &p_playlist->object_lock );
playlist_RecursiveNodeSort( p_playlist, p_item, i_mode, ORDER_NORMAL );
vlc_mutex_unlock(&p_playlist->object_lock );
vlc_mutex_unlock( &p_playlist->object_lock );
}
else
{
int i;
for (i = 0 ; i < p_item->i_parents ; i++)
for( i = 0 ; i < p_item->i_parents ; i++ )
{
if (p_item->pp_parents[i]->i_view == VIEW_SIMPLE)
if( p_item->pp_parents[i]->i_view == i_current_view )
{
vlc_mutex_lock(&p_playlist->object_lock );
vlc_mutex_lock( &p_playlist->object_lock );
playlist_RecursiveNodeSort( p_playlist,
p_item->pp_parents[i]->p_parent, i_mode, ORDER_NORMAL );
vlc_mutex_unlock(&p_playlist->object_lock );
vlc_mutex_unlock( &p_playlist->object_lock );
break;
}
}
}
vlc_object_release(p_playlist);
vlc_object_release( p_playlist );
[self playlistUpdated];
}
......@@ -519,7 +529,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
return;
}
for ( i_item = 0; i_item < (int)[o_array count]; i_item++ )
for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
{
/* One item */
NSDictionary *o_one_item;
......@@ -575,11 +585,6 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
i_position == -1 ? PLAYLIST_END : i_position + i_item,
0, (ppsz_options != NULL ) ? (const char **)ppsz_options : 0, i_total_options );
/* clean up
for( j = 0; j < i_total_options; j++ )
free( ppsz_options[j] );
if( ppsz_options ) free( ppsz_options ); */
/* Recent documents menu */
o_true_file = [NSURL fileURLWithPath: o_uri];
if( o_true_file != nil )
......@@ -601,16 +606,16 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
- (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;
}
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])
switch( [o_loop_popup indexOfSelectedItem] )
{
case 1:
......@@ -632,7 +637,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
default:
var_Get( p_playlist, "repeat", &val1 );
var_Get( p_playlist, "loop", &val2 );
if (val1.b_bool || val2.b_bool)
if( val1.b_bool || val2.b_bool )
{
val1.b_bool = 0;
var_Set( p_playlist, "repeat", val1 );
......@@ -647,12 +652,12 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
- (NSMutableArray *)subSearchItem:(playlist_item_t *)p_item
{
playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
playlist_item_t * p_selected_item;
playlist_item_t *p_selected_item;
int i_current, i_selected_row;
if (!p_playlist)
if( !p_playlist )
return NULL;
i_selected_row = [o_outline_view selectedRow];
......@@ -662,57 +667,57 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
p_selected_item = (playlist_item_t *)[[o_outline_view itemAtRow:
i_selected_row] pointerValue];
for (i_current = 0; i_current < p_item->i_children ; i_current++)
for( i_current = 0; i_current < p_item->i_children ; i_current++ )
{
char * psz_temp;
NSString * o_current_name, * o_current_author;
char *psz_temp;
NSString *o_current_name, *o_current_author;
vlc_mutex_lock( &p_playlist->object_lock );
o_current_name = [NSString stringWithUTF8String:
p_item->pp_children[i_current]->input.psz_name];
psz_temp = vlc_input_item_GetInfo(&p_item->input ,
psz_temp = vlc_input_item_GetInfo( &p_item->input ,
_("Meta-information"),_("Author") );
o_current_author = [NSString stringWithUTF8String: psz_temp];
free( psz_temp);
vlc_mutex_unlock( &p_playlist->object_lock );
if (p_selected_item == p_item->pp_children[i_current] &&
b_selected_item_met == NO)
if( p_selected_item == p_item->pp_children[i_current] &&
b_selected_item_met == NO )
{
b_selected_item_met = YES;
}
else if (p_selected_item == p_item->pp_children[i_current] &&
b_selected_item_met == YES)
else if( p_selected_item == p_item->pp_children[i_current] &&
b_selected_item_met == YES )
{
vlc_object_release(p_playlist);
vlc_object_release( p_playlist );
return NULL;
}
else if (b_selected_item_met == YES &&
([o_current_name rangeOfString:[o_search_field
else if( b_selected_item_met == YES &&
( [o_current_name rangeOfString:[o_search_field
stringValue] options:NSCaseInsensitiveSearch ].length ||
[o_current_author rangeOfString:[o_search_field
stringValue] options:NSCaseInsensitiveSearch ].length))
[o_current_author rangeOfString:[o_search_field
stringValue] options:NSCaseInsensitiveSearch ].length ) )
{
vlc_object_release(p_playlist);
vlc_object_release( p_playlist );
/*Adds the parent items in the result array as well, so that we can
expand the tree*/
return [NSMutableArray arrayWithObject: [NSValue
valueWithPointer: p_item->pp_children[i_current]]];
}
if (p_item->pp_children[i_current]->i_children > 0)
if( p_item->pp_children[i_current]->i_children > 0 )
{
id o_result = [self subSearchItem:
p_item->pp_children[i_current]];
if (o_result != NULL)
if( o_result != NULL )
{
vlc_object_release(p_playlist);
vlc_object_release( p_playlist );
[o_result insertObject: [NSValue valueWithPointer:
p_item->pp_children[i_current]] atIndex:0];
return o_result;
}
}
}
vlc_object_release(p_playlist);
vlc_object_release( p_playlist );
return NULL;
}
......@@ -731,21 +736,21 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
if( p_playlist == NULL )
return;
p_view = playlist_ViewFind( p_playlist, VIEW_SIMPLE );
p_view = playlist_ViewFind( p_playlist, i_current_view );
if (p_view)
if( p_view )
{
/*First, only search after the selected item:*
*(b_selected_item_met = NO) */
o_result = [self subSearchItem:p_view->p_root];
if (o_result == NULL)
if( o_result == NULL )
{
/* If the first search failed, search again from the beginning */
o_result = [self subSearchItem:p_view->p_root];
}
if (o_result != NULL)
if( o_result != NULL )
{
for (i = 0 ; i < [o_result count] - 1 ; i++)
for( i = 0 ; i < [o_result count] - 1 ; i++ )
{
[o_outline_view expandItem: [o_outline_dict objectForKey:
[NSString stringWithFormat: @"%p",
......@@ -756,14 +761,13 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
[[o_result objectAtIndex: [o_result count] - 1 ]
pointerValue]]]];
}
if (i_row > -1)
if( i_row > -1 )
{
[o_outline_view selectRow:i_row byExtendingSelection: NO];
[o_outline_view scrollRowToVisible: i_row];
}
}
vlc_object_release(p_playlist);