Ignore:
Timestamp:
Sep 10, 2007, 8:05:24 PM (15 years ago)
Author:
livings124
Message:

use images for error levels...it needs better images

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/MessageWindowController.m

    r3035 r3036  
    5151                    selector: @selector(updateLog:) userInfo: nil repeats: YES];
    5252       
    53         int level = [[NSUserDefaults standardUserDefaults] integerForKey: @"MessageLevel"];
    54         if (level == TR_MSG_ERR)
    55             [fLevelButton selectItemAtIndex: LEVEL_ERROR];
    56         else if (level == TR_MSG_INF)
    57             [fLevelButton selectItemAtIndex: LEVEL_INFO];
    58         else if (level == TR_MSG_DBG)
    59             [fLevelButton selectItemAtIndex: LEVEL_DEBUG];
    60         else
    61         {
    62             level = TR_MSG_ERR;
    63             [fLevelButton selectItemAtIndex: LEVEL_ERROR];
    64             [[NSUserDefaults standardUserDefaults] setInteger: level forKey: @"MessageLevel"];
    65         }
    66        
    67         tr_setMessageLevel(level);
     53        tr_setMessageLevel([[NSUserDefaults standardUserDefaults] integerForKey: @"MessageLevel"]);
    6854        tr_setMessageQueuing(1);
    6955    }
     
    8369    [[self window] center];
    8470   
     71    fErrorImage = [NSImage imageNamed: @"RedDot.tiff"];
     72    fInfoImage = [NSImage imageNamed: @"YellowDot.tiff"];
     73    fDebugImage = [NSImage imageNamed: @"GreenDot.tiff"];
     74   
     75    //set images to popup button items
     76    [[fLevelButton itemAtIndex: LEVEL_ERROR] setImage: fErrorImage];
     77    [[fLevelButton itemAtIndex: LEVEL_INFO] setImage: fInfoImage];
     78    [[fLevelButton itemAtIndex: LEVEL_DEBUG] setImage: fDebugImage];
     79   
     80    //select proper level in popup button
    8581    int level = tr_getMessageLevel();
    8682    if (level == TR_MSG_ERR)
     
    106102        return;
    107103   
    108     NSString * levelString;
    109104    for (currentMessage = messages; currentMessage != NULL; currentMessage = currentMessage->next)
    110     {
    111         int level = currentMessage->level;
    112         if (level == TR_MSG_ERR)
    113             levelString = @"Error";
    114         else if (level == TR_MSG_INF)
    115             levelString = @"Info";
    116         else if (level == TR_MSG_DBG)
    117             levelString = @"Debug";
    118         else
    119             levelString = @"???";
    120        
    121         //remove the first line if at max number of lines
    122         /*if (fLines == MAX_LINES)
    123         {
    124             unsigned int loc = [[fTextView string] rangeOfString: @"\n"].location;
    125             if (loc != NSNotFound)
    126                 [[fTextView textStorage] deleteCharactersInRange: NSMakeRange(0, loc + 1)];
    127         }*/
    128        
    129105        [fMessages addObject: [NSDictionary dictionaryWithObjectsAndKeys:
    130106                                [NSString stringWithUTF8String: currentMessage->message], @"Message",
    131107                                [NSDate dateWithTimeIntervalSince1970: currentMessage->when], @"Date",
    132                                 levelString, @"Level", nil]];
    133     }
     108                                [NSNumber numberWithInt: currentMessage->level], @"Level", nil]];
    134109   
    135110    #warning still needed?
     
    156131        return [message objectForKey: @"Date"];
    157132    else if ([ident isEqualToString: @"Level"])
    158         return [message objectForKey: @"Level"];
     133    {
     134        int level = [[message objectForKey: @"Level"] intValue];
     135        if (level == TR_MSG_ERR)
     136            return fErrorImage;
     137        else if (level == TR_MSG_INF)
     138            return fInfoImage;
     139        else if (level == TR_MSG_DBG)
     140            return fDebugImage;
     141        else
     142            return nil;
     143    }
    159144    else
    160145        return [message objectForKey: @"Message"];
     
    241226- (NSString *) stringForMessage: (NSDictionary *) message
    242227{
    243     return [NSString stringWithFormat: @"%@ %@ %@", [message objectForKey: @"Date"],
    244                 [message objectForKey: @"Level"], [message objectForKey: @"Message"]];
     228    int level = [[message objectForKey: @"Level"] intValue];
     229    NSString * levelString;
     230    if (level == TR_MSG_ERR)
     231        levelString = @"Error";
     232    else if (level == TR_MSG_INF)
     233        levelString = @"Info";
     234    else if (level == TR_MSG_DBG)
     235        levelString = @"Debug";
     236    else
     237        levelString = @"???";
     238   
     239    return [NSString stringWithFormat: @"%@ %@ %@", [message objectForKey: @"Date"], levelString, [message objectForKey: @"Message"]];
    245240}
    246241
Note: See TracChangeset for help on using the changeset viewer.