]> git.sesse.net Git - vlc/commitdiff
macosx: Use input_ItemHasErrorWhenReading to display a small icon if there was an...
authorPierre d'Herbemont <pdherbemont@videolan.org>
Fri, 1 Aug 2008 20:49:38 +0000 (22:49 +0200)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Fri, 1 Aug 2008 20:52:49 +0000 (22:52 +0200)
Regarding the new look, feel free to improve.

extras/package/macosx/Resources/English.lproj/MainMenu.nib/info.nib
extras/package/macosx/Resources/English.lproj/MainMenu.nib/keyedobjects.nib
modules/gui/macosx/interaction.h
modules/gui/macosx/interaction.m
modules/gui/macosx/misc.h
modules/gui/macosx/misc.m
modules/gui/macosx/playlist.m

index f71a76960a73e689b4dc038193d56843d9d3f9e5..624fd7a254d76fbc03bf20f6c13144e1de62a17d 100644 (file)
        <integer>5</integer>
        <key>IBOpenObjects</key>
        <array>
-               <integer>29</integer>
-               <integer>21</integer>
-               <integer>2417</integer>
-               <integer>915</integer>
+               <integer>2211</integer>
        </array>
        <key>IBSystem Version</key>
        <string>9E17</string>
index 4e7966638157abf2e01f43f8cd4bfd3e5219c652..96a39abc11166469c49add82e31447b5442de362 100644 (file)
Binary files a/extras/package/macosx/Resources/English.lproj/MainMenu.nib/keyedobjects.nib and b/extras/package/macosx/Resources/English.lproj/MainMenu.nib/keyedobjects.nib differ
index 81bb98a738d8454240027627a0698bafd0cb34dd..bde4badb3cfdfebbb78fffc44e06aed9517e967f 100644 (file)
@@ -86,9 +86,6 @@
     NSMutableArray * o_errors;
     NSMutableArray * o_icons;
 
-    NSImage * warnIcon;
-    NSImage * errorIcon;
-
     BOOL nib_interact_errpanel_loaded;
 }
 - (IBAction)cleanupTable:(id)sender;
index 4dd7fda7dd25abb6af53b00fff093e2b3068f3bb..c62e36c4fcb93f38ac78b9ac9b0faac0074d3854 100644 (file)
@@ -24,6 +24,7 @@
 
 #import "intf.h"
 #import "interaction.h"
+#import "misc.h"
 
 /* for the icons in our custom error panel */
 #import <ApplicationServices/ApplicationServices.h>
     o_errors = [[NSMutableArray alloc] init];
     o_icons = [[NSMutableArray alloc] init];
 
-    /* ugly Carbon stuff following...
-     * regrettably, you can't get the icons through clean Cocoa */
-
-    /* retrieve our error icon */
-    IconRef ourIconRef;
-    int returnValue;
-    returnValue = GetIconRef(kOnSystemDisk, 'macs', 'stop', &ourIconRef);
-    errorIcon = [[NSImage alloc] initWithSize:NSMakeSize(32,32)];
-    [errorIcon lockFocus];
-    CGRect rect = CGRectMake(0,0,32,32);
-    PlotIconRefInContext((CGContextRef)[[NSGraphicsContext currentContext]
-        graphicsPort],
-        &rect,
-        kAlignNone,
-        kTransformNone,
-        NULL /*inLabelColor*/,
-        kPlotIconRefNormalFlags,
-        (IconRef)ourIconRef);
-    [errorIcon unlockFocus];
-    returnValue = ReleaseIconRef(ourIconRef);
-
-    /* retrieve our caution icon */
-    returnValue = GetIconRef(kOnSystemDisk, 'macs', 'caut', &ourIconRef);
-    warnIcon = [[NSImage alloc] initWithSize:NSMakeSize(32,32)];
-    [warnIcon lockFocus];
-    PlotIconRefInContext((CGContextRef)[[NSGraphicsContext currentContext]
-        graphicsPort],
-        &rect,
-        kAlignNone,
-        kTransformNone,
-        NULL /*inLabelColor*/,
-        kPlotIconRefNormalFlags,
-        (IconRef)ourIconRef);
-    [warnIcon unlockFocus];
-    returnValue = ReleaseIconRef(ourIconRef);
-
     return self;
 }
 
 -(void)dealloc
 {
-    [errorIcon release];
-    [warnIcon release];
     [o_errors release];
     [o_icons release];
     [super dealloc];
     [o_errors addObject: ourError];
     [ourError release];
 
-    [o_icons addObject: errorIcon];
+    [o_icons addObject: [NSImage imageWithErrorIcon]];
 
     [o_error_table reloadData];
-    [self showPanel];
 }
 
 -(void)addWarning: (NSString *)o_warning withMsg:(NSString *)o_msg
     [o_errors addObject: ourWarning];
     [ourWarning release];
 
-    [o_icons addObject: warnIcon];
+    [o_icons addObject: [NSImage imageWithWarningIcon]];
  
     [o_error_table reloadData];
-
-    [self showPanel];
 }
 
 -(IBAction)cleanupTable:(id)sender
index fe06daaf7c14c330ceba47f53392d38596ed6986..a27f87cc529a7763bfbc3ef0eea13067d4466c31 100644 (file)
 #import <Cocoa/Cocoa.h>
 #import <ApplicationServices/ApplicationServices.h>
 
+/*****************************************************************************
+ * NSImage (VLCAddition)
+ *****************************************************************************/
+
+@interface NSImage (VLCAdditions)
++ (id)imageWithWarningIcon;
++ (id)imageWithErrorIcon;
+@end
+
 /*****************************************************************************
  * NSAnimation (VLCAddition)
  *****************************************************************************/
index a4deccee74cebd3275c120d88890ece52ddb6af2..3a033f820aed22e43137cceaba0b5a8dbccd8d9e 100644 (file)
 #import "playlist.h"
 #import "controls.h"
 
+/*****************************************************************************
+ * NSImage (VLCAdditions)
+ *
+ *  Addition to NSImage
+ *****************************************************************************/
+@implementation NSImage (VLCAdditions)
++ (id)imageWithSystemName:(int)name
+{
+    /* ugly Carbon stuff following...
+     * regrettably, you can't get the icons through clean Cocoa */
+
+    /* retrieve our error icon */
+    NSImage * icon;
+    IconRef ourIconRef;
+    int returnValue;
+    returnValue = GetIconRef(kOnSystemDisk, 'macs', name, &ourIconRef);
+    icon = [[[NSImage alloc] initWithSize:NSMakeSize(32,32)] autorelease];
+    [icon lockFocus];
+    CGRect rect = CGRectMake(0,0,32,32);
+    PlotIconRefInContext((CGContextRef)[[NSGraphicsContext currentContext]
+        graphicsPort],
+        &rect,
+        kAlignNone,
+        kTransformNone,
+        NULL /*inLabelColor*/,
+        kPlotIconRefNormalFlags,
+        (IconRef)ourIconRef);
+    [icon unlockFocus];
+    returnValue = ReleaseIconRef(ourIconRef);
+    return icon;
+}
+
++ (id)imageWithWarningIcon
+{
+    static NSImage * imageWithWarningIcon = nil;
+    if( !imageWithWarningIcon )
+    {
+        imageWithWarningIcon = [[[self class] imageWithSystemName:'caut'] retain];
+    }
+    return imageWithWarningIcon;
+}
+
++ (id)imageWithErrorIcon
+{
+    static NSImage * imageWithErrorIcon = nil;
+    if( !imageWithErrorIcon )
+    {
+        imageWithErrorIcon = [[[self class] imageWithSystemName:'stop'] retain];
+    }
+    return imageWithErrorIcon;
+}
+
+@end
 /*****************************************************************************
  * NSAnimation (VLCAdditions)
  *
index a01e714b37751cdc6718e83385329977192f0ae3..f9e6e8efd6a3c8b7b65c5e695148eba63f3b3fa8 100644 (file)
  
     attempted_reload = NO;
 
-    if( [[o_tc identifier] isEqualToString:@"1"] )
+    if( [[o_tc identifier] isEqualToString:@"name"] )
     {
         /* sanity check to prevent the NSString class from crashing */
         char *psz_title =  input_item_GetTitle( p_item->p_input );
         else
         {
             char *psz_name = input_item_GetName( p_item->p_input );
-            if( !EMPTY_STR( psz_name ) )
-            {
+            if( psz_name )
                 o_value = [NSString stringWithUTF8String: psz_name];
-            }
             free( psz_name );
         }
         free( psz_title );
     }
-    else
+    else if( [[o_tc identifier] isEqualToString:@"artist"] )
     {
         char *psz_artist = input_item_GetArtist( p_item->p_input );
-        if( [[o_tc identifier] isEqualToString:@"2"] && !EMPTY_STR( psz_artist ) )
-        {
+        if( psz_artist )
             o_value = [NSString stringWithUTF8String: psz_artist];
+        free( psz_artist );
+    }
+    else if( [[o_tc identifier] isEqualToString:@"duration"] )
+    {
+        char psz_duration[MSTRTIME_MAX_SIZE];
+        mtime_t dur = input_item_GetDuration( p_item->p_input );
+        if( dur != -1 )
+        {
+            secstotimestr( psz_duration, dur/1000000 );
+            o_value = [NSString stringWithUTF8String: psz_duration];
         }
-        else if( [[o_tc identifier] isEqualToString:@"3"] )
+        else
+            o_value = @"--:--";
+    }
+    else if( [[o_tc identifier] isEqualToString:@"status"] )
+    {
+        if( input_ItemHasErrorWhenReading( p_item->p_input ) )
         {
-            char psz_duration[MSTRTIME_MAX_SIZE];
-            mtime_t dur = input_item_GetDuration( p_item->p_input );
-            if( dur != -1 )
-            {
-                secstotimestr( psz_duration, dur/1000000 );
-                o_value = [NSString stringWithUTF8String: psz_duration];
-            }
-            else
-            {
-                o_value = @"--:--";
-            }
+            o_value = [NSImage imageWithWarningIcon];
         }
-        free( psz_artist );
     }
     return o_value;
 }
     return self;
 }
 
+- (void)dealloc
+{
+    [o_nodes_array release];
+    [o_items_array release];
+    [super dealloc];
+}
+
 - (void)awakeFromNib
 {
     playlist_t * p_playlist = pl_Yield( VLCIntf );