]> git.sesse.net Git - vlc/commitdiff
macosx: fixed table column duplication by moving the dynamic column generation from...
authorFelix Paul Kühne <fkuehne@videolan.org>
Mon, 11 Jun 2012 12:00:32 +0000 (14:00 +0200)
committerFelix Paul Kühne <fkuehne@videolan.org>
Mon, 11 Jun 2012 12:00:32 +0000 (14:00 +0200)
extras/package/macosx/Resources/English.lproj/MainMenu.xib
modules/gui/macosx/playlist.h
modules/gui/macosx/playlist.m

index 45a79a93b8820176a508169c84411cf66e133791..4362622796b31b1a76eaa90be33d92636403e945 100644 (file)
     </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>
                               <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>
index 2d770a26644af5c9c048d8402d49d72242d533e0..433bd1396fa3534343fbfeb83f354170b768f1da 100644 (file)
@@ -65,8 +65,6 @@
 - (playlist_item_t *)currentPlaylistRoot;
 - (playlist_item_t *)selectedPlaylistItem;
 - (NSOutlineView *)outlineView;
-
-- (void)setColumn: (NSString *)o_column state: (NSInteger)i_state;
 @end
 
 /*****************************************************************************
 
 - (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
index abad412b8fd796c2a82b62bc94cd6dcb93e6da32..215ccf18831514fbb04305aa5c2272e8dcf980ea 100644 (file)
  *****************************************************************************/
 @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 );
     [[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
                                                                 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)
  *****************************************************************************/
 @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];
     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
     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];
 {
     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)