]> git.sesse.net Git - vlc/commitdiff
* Fixed Meta for OSX, so i know what music i'm listening to.
authorDerk-Jan Hartman <hartman@videolan.org>
Tue, 16 May 2006 22:29:39 +0000 (22:29 +0000)
committerDerk-Jan Hartman <hartman@videolan.org>
Tue, 16 May 2006 22:29:39 +0000 (22:29 +0000)
(debug left in place. when you run into a crash please not the console info so we can investigate)

modules/gui/macosx/playlist.m
modules/gui/macosx/playlistinfo.m

index ec4dbac0eeb4d70e9f5ab320e50abc7ba4362d39..7194039bb41b038433f26e4e38edb76e75b53e55 100644 (file)
 - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
 {
     int i_return = 0;
+    playlist_item_t *p_item = NULL;
     playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
                                                        FIND_ANYWHERE );
     if( p_playlist == NULL )
     if( item == nil )
     {
         /* root object */
-        if( p_playlist->p_root_category )
-        {
-            i_return = p_playlist->p_root_category->i_children;
-        }
+        p_item = p_playlist->p_root_category;
     }
     else
     {
-        playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
-        if( p_item )
-            i_return = p_item->i_children;
+        p_item = (playlist_item_t *)[item pointerValue];
     }
+    if( p_item )
+            i_return = p_item->i_children;
     vlc_object_release( p_playlist );
 
     if( i_return <= 0 )
         i_return = 0;
-
+NSLog( @"%d children for %s", i_return, p_item->p_input->psz_name ); 
     return i_return;
 }
 
 /* return the child at index for the Obj-C pointer item */ /* DONE */
 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
 {
-    playlist_item_t *p_return = NULL;
+    playlist_item_t *p_return = NULL, *p_item = NULL;
+    NSValue *o_value;
     playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
                                                        FIND_ANYWHERE );
-    NSValue *o_value;
 
     if( p_playlist == NULL )
         return nil;
     if( item == nil )
     {
         /* root object */
-        if( p_playlist->p_root_category )
-        {
-            p_return = p_playlist->p_root_category->pp_children[index];
-        }
+        p_item = p_playlist->p_root_category;
     }
     else
     {
-        playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
-        if( p_item && index < p_item->i_children && index >= 0 )
-            p_return = p_item->pp_children[index];
+        p_item = (playlist_item_t *)[item pointerValue];      
     }
-
+    if( p_item && index < p_item->i_children && index >= 0 )
+        p_return = p_item->pp_children[index];
+    
     vlc_object_release( p_playlist );
 
     o_value = [o_outline_dict objectForKey:[NSString stringWithFormat: @"%p", p_return]];
+    NSLog( @"%s", p_return->p_input->psz_name);
     if( o_value == nil )
     {
         o_value = [[NSValue valueWithPointer: p_return] retain];
+        NSLog( @"error missing value" );
     }
     return o_value;
 }
 - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
 {
     int i_return = 0;
-    playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
+    playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
                                                        FIND_ANYWHERE );
     if( p_playlist == NULL )
         return NO;
     }
     vlc_object_release( p_playlist );
 
+NSLog( @"expandable" ); 
     if( i_return <= 0 )
         return NO;
     else
     
     if( item == nil || ![item isKindOfClass: [NSValue class]] ) return( @"error" );
     
-    p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                               FIND_ANYWHERE );
-    if( p_playlist == NULL )
-    {
-        return( @"error" );
-    }
-
+    /* Check to see if the playlist is present */
+    p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    if( p_playlist == NULL ) return( @"error");
+    vlc_object_release( p_playlist);
+    
     p_item = (playlist_item_t *)[item pointerValue];
-
     if( p_item == NULL )
     {
-        vlc_object_release( p_playlist );
         return( @"error");
     }
-
+NSLog( @"values for %p", p_item ); 
+    
     if( [[o_tc identifier] isEqualToString:@"1"] )
     {
         o_value = [NSString stringWithUTF8String:
             o_value = [NSString stringWithCString:
                 p_item->p_input->psz_name];
     }
-    else if( [[o_tc identifier] isEqualToString:@"2"] )
+    else if( [[o_tc identifier] isEqualToString:@"2"] && p_item->p_input->p_meta &&
+        p_item->p_input->p_meta->psz_artist && *p_item->p_input->p_meta->psz_artist )
     {
-        char *psz_temp;
-        psz_temp = vlc_input_item_GetInfo( p_item->p_input ,_("Meta-information"),_("Artist") );
-
-        if( psz_temp == NULL )
-            o_value = @"";
-        else
-        {
-            o_value = [NSString stringWithUTF8String: psz_temp];
-            if( o_value == NULL )
-            {
-                o_value = [NSString stringWithCString: psz_temp];
-            }
-            free( psz_temp );
-        }
+        o_value = [NSString stringWithUTF8String:
+            p_item->p_input->p_meta->psz_artist];
+        if( o_value == NULL )
+            o_value = [NSString stringWithCString:
+                p_item->p_input->p_meta->psz_artist];
     }
     else if( [[o_tc identifier] isEqualToString:@"3"] )
     {
             o_value = @"-:--:--";
         }
     }
-    vlc_object_release( p_playlist );
 
     return( o_value );
 }
@@ -1545,7 +1531,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
 
     [o_outline_dict setObject:o_value forKey:[NSString stringWithFormat:@"%p",
                                                     [o_value pointerValue]]];
-
+NSLog( @"add item %p", [o_value pointerValue] );
     return o_value;
 
 }
index 8869e8d9382ca9bb5e1865e9a15f6d5477d34114..2ee9f0071a9cb44f42a68d2b3b8d05bff7e81b36 100644 (file)
     /* check whether our item is valid, because we would crash if not */
     if(! [self isItemInPlaylist: p_item] ) return;
 
-    char *psz_temp;
     vlc_mutex_lock( &p_item->p_input->lock );
 
     /* fill uri / title / author info */
             [NSString stringWithCString:p_item->p_input->psz_name] :
             [NSString stringWithUTF8String:p_item->p_input->psz_name]];
     }
-    vlc_mutex_unlock( &p_item->p_input->lock );
-
-    psz_temp = vlc_input_item_GetInfo( p_item->p_input, _("Meta-information"), _("Artist") );
-
-    if( psz_temp )
-    {
-        [o_author_txt setStringValue: [NSString stringWithUTF8String: psz_temp]];
-        free( psz_temp );
-    }
 
     /* fill the other fields */
-    [self setMeta: VLC_META_GENRE forLabel: o_genre_txt];
-    [self setMeta: VLC_META_COPYRIGHT forLabel: o_copyright_txt];
-    [self setMeta: VLC_META_COLLECTION forLabel: o_collection_txt];
-    [self setMeta: VLC_META_SEQ_NUM forLabel: o_seqNum_txt];
-    [self setMeta: VLC_META_DESCRIPTION forLabel: o_description_txt];
-    [self setMeta: VLC_META_RATING forLabel: o_rating_txt];
-    [self setMeta: VLC_META_DATE forLabel: o_date_txt];
-    [self setMeta: VLC_META_LANGUAGE forLabel: o_language_txt];
-    [self setMeta: VLC_META_NOW_PLAYING forLabel: o_nowPlaying_txt];
-    [self setMeta: VLC_META_PUBLISHER forLabel: o_publisher_txt];
+#define p_m p_item->p_input->p_meta
+    [self setMeta: p_m->psz_artist forLabel: o_author_txt];
+    [self setMeta: p_m->psz_album forLabel: o_collection_txt];
+    [self setMeta: p_m->psz_tracknum forLabel: o_seqNum_txt];
+    [self setMeta: p_m->psz_genre forLabel: o_genre_txt];
+    [self setMeta: p_m->psz_copyright forLabel: o_copyright_txt];
+    [self setMeta: p_m->psz_rating forLabel: o_rating_txt];
+    [self setMeta: p_m->psz_publisher forLabel: o_publisher_txt];
+    [self setMeta: p_m->psz_nowplaying forLabel: o_nowPlaying_txt];
+    [self setMeta: p_m->psz_language forLabel: o_language_txt];
+    [self setMeta: p_m->psz_date forLabel: o_date_txt];
+#undef p_m
+    vlc_mutex_unlock( &p_item->p_input->lock );
 
     /* reload the advanced table */
     [[VLCInfoTreeItem rootItem] refresh];
     [self updateStatistics: nil];
 }
 
-- (void)setMeta: (char *)meta forLabel: (id)theItem
+- (void)setMeta: (char *)psz_meta forLabel: (id)theItem
 {
-    char *psz_meta = vlc_input_item_GetInfo( p_item->p_input, \
-        _(VLC_META_INFO_CAT), _(meta) );
     if( psz_meta != NULL && *psz_meta)
-        [theItem setStringValue: [NSString stringWithUTF8String: psz_meta]];
+        [theItem setStringValue: 
+            ([NSString stringWithUTF8String:psz_meta] == nil ) ? 
+            [NSString stringWithCString:psz_meta] :
+            [NSString stringWithUTF8String:psz_meta]];
     else
         [theItem setStringValue: @"-"];
 }
 
         p_item->p_input->psz_uri = strdup( [[o_uri_txt stringValue] UTF8String] );
         p_item->p_input->psz_name = strdup( [[o_title_txt stringValue] UTF8String] );
+        vlc_meta_SetArtist( p_item->p_input->p_meta, [[o_author_txt stringValue] UTF8String] )
         vlc_mutex_unlock( &p_item->p_input->lock );
-        vlc_input_item_AddInfo( p_item->p_input, _("Meta-information"), _("Artist"), [[o_author_txt stringValue] UTF8String]);
-        
+
         val.b_bool = VLC_TRUE;
         var_Set( p_playlist, "intf-change", val );
     }