Ignore:
Timestamp:
03/01/08 02:58:52 (12 years ago)
Author:
Nicholas Riley
Message:

English.lproj/APE Manager plugin.nib: Wording cleanups; the edit
button works now.

English.lproj/APEInfo.rtfd: Updated for 1.5b1.

English.lproj/Select services.nib: Removed reference to
non-highlighting outline view; use source list highlighting on
Leopard.

ICeCoffEE.xcodeproj: More decruftification.

ICeCoffEEInvertingTextFieldCell.[hm]: Non-colored text becomes white
(why doesn't Apple's implementation do this?).

ICeCoffEEServicePrefController.m: Service shown/hidden/mixed
selections slightly more abstracted, and now stored in tags rather
than represented object (which is already in use). Still no
localization support. Fix scroll bar non-appearance.

Installer components/ui/ui.plist: Replaced version info with empty
placeholders since it's now script-populated; require OS X 10.5 until
I've had a chance to test on an earlier version.

VERSION.xcconfig: Updated for 1.5b1.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEServicePrefController.m

    r320 r425  
    1111#import "ICeCoffEEServicePrefController.h"
    1212#import "ICeCoffEENonHighlightingButtonCell.h"
    13 #import "ICeCoffEENonHighlightingTextFieldCell.h"
     13#import "ICeCoffEEInvertingTextFieldCell.h"
    1414#import "ICeCoffEELabeledIconCell.h"
    1515#import <objc/objc.h>
    1616#import <ApplicationEnhancer/ApplicationEnhancer.h>
    1717
    18 static NSNumber *ICCF_SERVICE_SHOWN, *ICCF_SERVICE_HIDDEN, *ICCF_SERVICE_MIXED;
     18const int ICCF_SERVICE_UNKNOWN = 0;
     19const int ICCF_SERVICE_SHOWN = 1;
     20const int ICCF_SERVICE_HIDDEN = 2;
     21const int ICCF_SERVICE_MIXED = 3;
     22
    1923static NSDictionary *ICCF_SERVICE_OPTION_HIDDEN;
    2024
     
    6165}
    6266
    63 static inline void ICCF_UpdateKeyEquivalentForItem(NSMenuItem *item, id state) {
    64     NSNumber *oldState = [item representedObject];
    65     if ((oldState == nil || oldState == ICCF_SERVICE_SHOWN) && state == ICCF_SERVICE_HIDDEN)
     67static int ICCF_GetServiceState(NSMenuItem *item) {
     68    return [item tag];
     69}
     70
     71static void ICCF_SetServiceState(NSMenuItem *item, int state) {
     72    [item setTag: state];
     73}
     74
     75static inline void ICCF_UpdateKeyEquivalentForItem(NSMenuItem *item, int state) {
     76    int oldState = ICCF_GetServiceState(item);
     77    if ((oldState == ICCF_SERVICE_UNKNOWN || oldState == ICCF_SERVICE_SHOWN) && state == ICCF_SERVICE_HIDDEN)
    6678        ICCF_RemoveKeyEquivalentForItem(item);
    67     else if (oldState == ICCF_SERVICE_HIDDEN && (state == ICCF_SERVICE_SHOWN || state == nil))
     79    else if (oldState == ICCF_SERVICE_HIDDEN && (state == ICCF_SERVICE_SHOWN || state == ICCF_SERVICE_UNKNOWN))
    6880        ICCF_AddKeyEquivalentForItem(item);
    6981}
    7082
     83
    7184static inline NSCellStateValue ICCF_ServiceItemState(NSMenuItem *item) {
    72     id state = [item representedObject];
    73     return (state == nil) ? NSOnState : [state intValue];
    74 }
    75 
    76 static void ICCF_PropagateServiceStateChange(NSMenu *menu, id state) {
     85    int state = ICCF_GetServiceState(item);
     86    if (state == ICCF_SERVICE_HIDDEN)
     87        return NSOffState;
     88    if (state == ICCF_SERVICE_MIXED)
     89            return NSMixedState;
     90    return NSOnState;
     91}
     92
     93static void ICCF_PropagateServiceStateChange(NSMenu *menu, int state) {
    7794    NSEnumerator *e = [[menu itemArray] objectEnumerator];
    7895    NSMenuItem *item;
     
    86103            ICCF_UpdateKeyEquivalentForItem(item, state);
    87104       
    88         [item setRepresentedObject: state];
     105        ICCF_SetServiceState(item, state);
    89106    }
    90107}
     
    94111    if (submenu == nil) return ICCF_ServiceItemState(item);
    95112
    96     if (item == changedItem) ICCF_PropagateServiceStateChange(submenu, [item representedObject]);
     113    if (item == changedItem) ICCF_PropagateServiceStateChange(submenu, [item tag]);
    97114
    98115    BOOL areOn = NO, areOff = NO;
     
    108125                break;
    109126        }
    110         [item setRepresentedObject: ICCF_SERVICE_MIXED];
     127        ICCF_SetServiceState(item, ICCF_SERVICE_MIXED);
    111128        return NSMixedState;
    112129    }
    113130    if (areOn) {
    114         [item setRepresentedObject: ICCF_SERVICE_SHOWN];
     131        ICCF_SetServiceState(item, ICCF_SERVICE_SHOWN);
    115132        return NSOnState;
    116133    } else {
    117         [item setRepresentedObject: ICCF_SERVICE_HIDDEN];
     134        ICCF_SetServiceState(item, ICCF_SERVICE_HIDDEN);
    118135        return NSOffState;
    119136    }
     
    159176        subDict = [dict objectForKey: itemTitle];
    160177        if ([[subDict objectForKey: (NSString *)kICServiceHidden] boolValue]) {
    161             [item setRepresentedObject: ICCF_SERVICE_HIDDEN];
     178            ICCF_SetServiceState(item, ICCF_SERVICE_HIDDEN);
    162179            ICCF_RemoveKeyEquivalentForItem(item);
    163180        }
     
    214231+ (void)initialize;
    215232{
    216     ICCF_SERVICE_SHOWN = [[NSNumber alloc] initWithInt: NSOnState];
    217     ICCF_SERVICE_HIDDEN = [[NSNumber alloc] initWithInt: NSOffState];
    218     ICCF_SERVICE_MIXED = [[NSNumber alloc] initWithInt: NSMixedState];
    219233    ICCF_SERVICE_OPTION_HIDDEN = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithBool: YES], kICServiceHidden, nil];
    220234}
     
    239253        [[serviceOutline tableColumnWithIdentifier: @"service"] setDataCell:
    240254            [ICeCoffEELabeledIconCell copyFromTextFieldCell: textFieldCell]];
    241 
     255       
    242256        textFieldCell = [[serviceOutline tableColumnWithIdentifier: @"key"] dataCell];
    243         ((struct objc_object *)textFieldCell)->isa = [ICeCoffEENonHighlightingTextFieldCell class];
     257        ((struct objc_object *)textFieldCell)->isa = [ICeCoffEEInvertingTextFieldCell class];
     258       
     259        [serviceOutline noteNumberOfRowsChanged]; // or we get no active scroll bar or initial selection
    244260
    245261        [window setResizeIncrements: NSMakeSize(1, ICCF_TableViewCellHeight(serviceOutline))];
     
    351367        return [[[NSAttributedString alloc] initWithString: [item title] attributes: attrDict] autorelease];
    352368    } else if ([[tableColumn identifier] isEqualToString: @"show"]) {
    353         id state = [item representedObject];
    354         if ([item submenu] != nil && state == nil) {
     369        int state = ICCF_GetServiceState(item);
     370        if ([item submenu] != nil && state == ICCF_SERVICE_UNKNOWN) {
    355371            return [NSNumber numberWithInt: ICCF_PropagateServiceState(item, nil)];
    356372        }
    357         return (state == nil) ? ICCF_SERVICE_SHOWN : state;
     373        return [NSNumber numberWithInt: ICCF_ServiceItemState(item)];
    358374    } else if ([[tableColumn identifier] isEqualToString: @"key"]) {
    359375        NSString *equivalent = [item toolTip];
     
    368384{
    369385    if ([[tableColumn identifier] isEqualToString: @"show"]) {
    370         NSNumber *newState = [object boolValue] ? nil : ICCF_SERVICE_HIDDEN;
     386        int newState = [object boolValue] ? ICCF_SERVICE_SHOWN : ICCF_SERVICE_HIDDEN;
    371387        ICCF_UpdateKeyEquivalentForItem(item, newState);
    372         [item setRepresentedObject: newState];
     388        ICCF_SetServiceState(item, newState);
    373389       
    374390        NSMenu *submenu = [item menu];
Note: See TracChangeset for help on using the changeset viewer.