Commit bc8f5562 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: fixed table column duplication by moving the dynamic column generation...

macosx: fixed table column duplication by moving the dynamic column generation from VLCPlaylistCommon to VLCPlaylist, where it belongs (close #6928)
parent 0baf709f
......@@ -21,16 +21,16 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="4948"/>
<integer value="2730"/>
<integer value="2770"/>
<integer value="4850"/>
<integer value="21"/>
<integer value="4948"/>
<integer value="4372"/>
<integer value="915"/>
<integer value="1617"/>
<integer value="4722"/>
<integer value="4596"/>
<integer value="2730"/>
<integer value="4850"/>
<integer value="5100"/>
<integer value="4722"/>
<integer value="1617"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
......@@ -445,10 +445,9 @@
<reference key="NSBackgroundColor" ref="885475112"/>
<reference key="NSGridColor" ref="756174976"/>
<double key="NSRowHeight">15</double>
<int key="NSTvFlags">-71303168</int>
<int key="NSTvFlags">-88080384</int>
<reference key="NSDelegate"/>
<reference key="NSDataSource"/>
<string key="NSAutosaveName">10thaniversary-mainPlaylistView</string>
<int key="NSGridStyleMask">1</int>
<int key="NSColumnAutoresizingStyle">4</int>
<int key="NSDraggingSourceMaskForLocal">15</int>
......
......@@ -65,8 +65,6 @@
- (playlist_item_t *)currentPlaylistRoot;
- (playlist_item_t *)selectedPlaylistItem;
- (NSOutlineView *)outlineView;
- (void)setColumn: (NSString *)o_column state: (NSInteger)i_state;
@end
/*****************************************************************************
......@@ -151,4 +149,6 @@
- (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue;
- (void)appendNodeArray:(NSArray*)o_array inNode:(playlist_item_t *)p_node atPos:(int)i_position enqueue:(BOOL)b_enqueue;
- (void)setColumn: (NSString *)o_column state: (NSInteger)i_state;
@end
......@@ -134,18 +134,6 @@
*****************************************************************************/
@implementation VLCPlaylistCommon
+ (void)initialize{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSMutableArray * o_columnArray = [[NSMutableArray alloc] init];
[o_columnArray addObject: [NSArray arrayWithObjects: TITLE_COLUMN, [NSNumber numberWithFloat: 190.], nil]];
[o_columnArray addObject: [NSArray arrayWithObjects: ARTIST_COLUMN, [NSNumber numberWithFloat: 95.], nil]];
[o_columnArray addObject: [NSArray arrayWithObjects: DURATION_COLUMN, [NSNumber numberWithFloat: 95.], nil]];
NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:[NSArray arrayWithArray:o_columnArray] forKey:@"PlaylistColumnSelection"];
[defaults registerDefaults:appDefaults];
[o_columnArray release];
}
- (id)init
{
playlist_t * p_playlist = pl_Get( VLCIntf );
......@@ -176,30 +164,6 @@
[[o_tc_name_other headerCell] setStringValue:_NS("Name")];
[[o_tc_author_other headerCell] setStringValue:_NS("Author")];
[[o_tc_duration_other headerCell] setStringValue:_NS("Duration")];
NSArray * o_columnArray = [[NSUserDefaults standardUserDefaults] arrayForKey:@"PlaylistColumnSelection"];
NSUInteger count = [o_columnArray count];
id o_menu = [[VLCMain sharedInstance] mainMenu];
NSString * o_column;
for (NSUInteger i = 0; i < count; i++)
{
o_column = [[o_columnArray objectAtIndex:i] objectAtIndex:0];
if ([o_column isEqualToString:@"status"])
continue;
[self setColumn: o_column state: NSOnState];
[o_menu setPlaylistColumnTableState: NSOnState forColumn: o_column];
[[o_outline_view tableColumnWithIdentifier: o_column] setWidth: [[[o_columnArray objectAtIndex:i] objectAtIndex:1] floatValue]];
}
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(applicationWillTerminate:) name: NSApplicationWillTerminateNotification object: nil];
}
- (void)applicationWillTerminate:(NSNotification *)notification
{
/* let's make sure we save the correct widths and positions, since this likely changed since the last time the user played with the column selection */
[self saveTableColumns];
}
- (void)setPlaylistRoot: (playlist_item_t *)root_item
......@@ -225,68 +189,6 @@
pointerValue];
}
- (void)setColumn: (NSString *)o_column state: (NSInteger)i_state
{
NSTableColumn * o_work_tc;
if (i_state == NSOnState)
{
o_work_tc = [[NSTableColumn alloc] initWithIdentifier: o_column];
[o_work_tc setEditable: NO];
[[o_work_tc dataCell] setFont: [NSFont controlContentFontOfSize:11.]];
/* we cannot use a makro here, because gettext isn't clever enough for that */
if ([o_column isEqualToString: TRACKNUM_COLUMN])
{
[o_work_tc setMaxWidth: 20.];
[[o_work_tc headerCell] setStringValue: @"#"];
}
else if ([o_column isEqualToString: TITLE_COLUMN])
{
[[o_work_tc headerCell] setStringValue: _NS("Name")];
[o_work_tc setResizingMask: NSTableColumnAutoresizingMask | NSTableColumnUserResizingMask];
}
else if ([o_column isEqualToString: ARTIST_COLUMN])
[[o_work_tc headerCell] setStringValue: _NS("Author")];
else if ([o_column isEqualToString: DURATION_COLUMN])
[[o_work_tc headerCell] setStringValue: _NS("Duration")];
else if ([o_column isEqualToString: GENRE_COLUMN])
[[o_work_tc headerCell] setStringValue: _NS("Genre")];
else if ([o_column isEqualToString: ALBUM_COLUMN])
[[o_work_tc headerCell] setStringValue: _NS("Album")];
else if ([o_column isEqualToString: DESCRIPTION_COLUMN])
[[o_work_tc headerCell] setStringValue: _NS("Description")];
else if ([o_column isEqualToString: DATE_COLUMN])
[[o_work_tc headerCell] setStringValue: _NS("Date")];
else if ([o_column isEqualToString: LANGUAGE_COLUMN])
[[o_work_tc headerCell] setStringValue: _NS("Language")];
[o_outline_view addTableColumn: o_work_tc];
[o_work_tc release];
[o_outline_view reloadData];
[o_outline_view setNeedsDisplay: YES];
}
else
[o_outline_view removeTableColumn: [o_outline_view tableColumnWithIdentifier: o_column]];
[self saveTableColumns];
}
- (void)saveTableColumns
{
NSMutableArray * o_arrayToSave = [[NSMutableArray alloc] init];
NSArray * o_columns = [o_outline_view tableColumns];
NSUInteger count = [o_columns count];
NSTableColumn * o_currentColumn;
for (NSUInteger i = 0; i < count; i++)
{
o_currentColumn = [o_columns objectAtIndex: i];
[o_arrayToSave addObject: [NSArray arrayWithObjects: [o_currentColumn identifier], [NSNumber numberWithFloat: [o_currentColumn width]], nil]];
}
[[NSUserDefaults standardUserDefaults] setObject: o_arrayToSave forKey:@"PlaylistColumnSelection"];
[o_arrayToSave release];
}
@end
@implementation VLCPlaylistCommon (NSOutlineViewDataSource)
......@@ -537,6 +439,18 @@
*****************************************************************************/
@implementation VLCPlaylist
+ (void)initialize{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSMutableArray * o_columnArray = [[NSMutableArray alloc] init];
[o_columnArray addObject: [NSArray arrayWithObjects: TITLE_COLUMN, [NSNumber numberWithFloat: 190.], nil]];
[o_columnArray addObject: [NSArray arrayWithObjects: ARTIST_COLUMN, [NSNumber numberWithFloat: 95.], nil]];
[o_columnArray addObject: [NSArray arrayWithObjects: DURATION_COLUMN, [NSNumber numberWithFloat: 95.], nil]];
NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:[NSArray arrayWithArray:o_columnArray] forKey:@"PlaylistColumnSelection"];
[defaults registerDefaults:appDefaults];
[o_columnArray release];
}
- (id)init
{
self = [super init];
......@@ -583,6 +497,30 @@
o_descendingSortingImage = [[NSOutlineView class] _defaultTableHeaderReverseSortImage];
o_tc_sortColumn = nil;
NSArray * o_columnArray = [[NSUserDefaults standardUserDefaults] arrayForKey:@"PlaylistColumnSelection"];
NSUInteger count = [o_columnArray count];
id o_menu = [[VLCMain sharedInstance] mainMenu];
NSString * o_column;
for (NSUInteger i = 0; i < count; i++)
{
o_column = [[o_columnArray objectAtIndex:i] objectAtIndex:0];
if ([o_column isEqualToString:@"status"])
continue;
[self setColumn: o_column state: NSOnState];
[o_menu setPlaylistColumnTableState: NSOnState forColumn: o_column];
[[o_outline_view tableColumnWithIdentifier: o_column] setWidth: [[[o_columnArray objectAtIndex:i] objectAtIndex:1] floatValue]];
}
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(applicationWillTerminate:) name: NSApplicationWillTerminateNotification object: nil];
}
- (void)applicationWillTerminate:(NSNotification *)notification
{
/* let's make sure we save the correct widths and positions, since this likely changed since the last time the user played with the column selection */
[self saveTableColumns];
}
- (void)searchfieldChanged:(NSNotification *)o_notification
......@@ -621,8 +559,7 @@
NSUInteger count = [[o_outline_view tableColumns] count];
for( NSUInteger i = 0 ; i < count ; i++ )
{
[o_outline_view setIndicatorImage:nil inTableColumn:
[[o_outline_view tableColumns] objectAtIndex:i]];
[o_outline_view setIndicatorImage:nil inTableColumn: [[o_outline_view tableColumns] objectAtIndex:i]];
}
[o_outline_view setHighlightedTableColumn:nil];
......@@ -1534,6 +1471,69 @@
{
return [[o_nodes_array arrayByAddingObjectsFromArray: o_items_array] retain];
}
- (void)setColumn: (NSString *)o_column state: (NSInteger)i_state
{
NSTableColumn * o_work_tc;
if (i_state == NSOnState)
{
o_work_tc = [[NSTableColumn alloc] initWithIdentifier: o_column];
[o_work_tc setEditable: NO];
[[o_work_tc dataCell] setFont: [NSFont controlContentFontOfSize:11.]];
/* we cannot use a makro here, because gettext isn't clever enough for that */
if ([o_column isEqualToString: TRACKNUM_COLUMN])
{
[o_work_tc setMaxWidth: 20.];
[[o_work_tc headerCell] setStringValue: @"#"];
}
else if ([o_column isEqualToString: TITLE_COLUMN])
{
[[o_work_tc headerCell] setStringValue: _NS("Name")];
[o_work_tc setResizingMask: NSTableColumnAutoresizingMask | NSTableColumnUserResizingMask];
}
else if ([o_column isEqualToString: ARTIST_COLUMN])
[[o_work_tc headerCell] setStringValue: _NS("Author")];
else if ([o_column isEqualToString: DURATION_COLUMN])
[[o_work_tc headerCell] setStringValue: _NS("Duration")];
else if ([o_column isEqualToString: GENRE_COLUMN])
[[o_work_tc headerCell] setStringValue: _NS("Genre")];
else if ([o_column isEqualToString: ALBUM_COLUMN])
[[o_work_tc headerCell] setStringValue: _NS("Album")];
else if ([o_column isEqualToString: DESCRIPTION_COLUMN])
[[o_work_tc headerCell] setStringValue: _NS("Description")];
else if ([o_column isEqualToString: DATE_COLUMN])
[[o_work_tc headerCell] setStringValue: _NS("Date")];
else if ([o_column isEqualToString: LANGUAGE_COLUMN])
[[o_work_tc headerCell] setStringValue: _NS("Language")];
[o_outline_view addTableColumn: o_work_tc];
[o_work_tc release];
[o_outline_view reloadData];
[o_outline_view setNeedsDisplay: YES];
}
else
[o_outline_view removeTableColumn: [o_outline_view tableColumnWithIdentifier: o_column]];
}
- (void)saveTableColumns
{
NSMutableArray * o_arrayToSave = [[NSMutableArray alloc] init];
NSArray * o_columns = [[NSArray alloc] initWithArray:[o_outline_view tableColumns]];
NSUInteger count = [o_columns count];
NSTableColumn * o_currentColumn;
for (NSUInteger i = 0; i < count; i++)
{
o_currentColumn = [o_columns objectAtIndex: i];
[o_arrayToSave addObject: [NSArray arrayWithObjects: [o_currentColumn identifier], [NSNumber numberWithFloat: [o_currentColumn width]], nil]];
}
[[NSUserDefaults standardUserDefaults] setObject: o_arrayToSave forKey:@"PlaylistColumnSelection"];
[[NSUserDefaults standardUserDefaults] synchronize];
[o_columns release];
[o_arrayToSave release];
}
@end
@implementation VLCPlaylist (NSOutlineViewDataSource)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment