Adium

Changeset 15039

Show
Ignore:
Timestamp:
01/22/2006 06:37:11 PM (3 years ago)
Author:
evands
Message:
  • Hide the Info and Accounts tab view items in the Get Info window for groups.
  • General code cleanup and efficiency

Fixes #2788

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Resources/ContactInfoWindow.nib/classes.nib

    r12756 r15039  
    11{ 
    22    IBClasses = ( 
    3         { 
    4             CLASS = AIAbstractListWindowController;  
    5             LANGUAGE = ObjC;  
    6             OUTLETS = { 
    7                 contactListView = AIMultiCellOutlineView;  
    8                 "scrollView_contactList" = AIAutoScrollView;  
    9             };  
    10             SUPERCLASS = AIWindowController;  
    11         },  
    123        { 
    134            CLASS = AIAlternatingRowOutlineView;  
     
    2314        {CLASS = AIAutoScrollView; LANGUAGE = ObjC; SUPERCLASS = NSScrollView; },  
    2415        { 
    25             ACTIONS = {addContact = id; closeWindow = id; removeContact = id; };  
     16            ACTIONS = {addContact = id; removeContact = id; };  
    2617            CLASS = AIContactInfoWindowController;  
    2718            LANGUAGE = ObjC;  
     
    3122                contactListView = AIListOutlineView;  
    3223                "drawer_metaContact" = NSDrawer;  
    33                 "imageView_userIcon" = ESImageViewWithImagePicker;  
     24                "imageView_userIcon" = AIImageViewWithImagePicker;  
    3425                "scrollView_contactList" = AIAutoScrollView;  
     26                "tabViewItem_accounts" = NSTabViewItem;  
     27                "tabViewItem_info" = NSTabViewItem;  
    3528                "tabView_category" = NSTabView;  
    3629                "textField_accountName" = NSTextField;  
  • trunk/Source/AIContactInfoWindowController.h

    r14825 r15039  
    2323@interface AIContactInfoWindowController : AIWindowController <AIListControllerDelegate> {       
    2424        IBOutlet                NSTabView                                               *tabView_category; 
     25         
     26        IBOutlet                NSTabViewItem                                   *tabViewItem_info; 
     27        IBOutlet                NSTabViewItem                                   *tabViewItem_accounts; 
     28        NSTabViewItem                                                                   *tabViewItem_lastSelectedForListContacts; 
     29 
    2530        IBOutlet                AIImageViewWithImagePicker              *imageView_userIcon; 
    2631        IBOutlet                NSTextField                                             *textField_accountName; 
     
    4853+ (void)closeInfoWindow; 
    4954- (void)configureForListObject:(AIListObject *)inObject; 
    50 - (void)configurePanes; 
    5155 
    5256- (IBAction)addContact:(id)sender; 
  • trunk/Source/AIContactInfoWindowController.m

    r14824 r15039  
    5252- (void)localizeTabViewItemTitles; 
    5353- (void)configureDrawer; 
     54- (void)configureVisiblityOfTabViewItemsForListObject:(AIListObject *)inObject; 
     55- (void)configurePanes:(NSArray *)inPanes; 
    5456- (void)setupMetaContactDrawer; 
    5557 
     
    108110} 
    109111 
    110 //init 
    111 - (id)initWithWindowNibName:(NSString *)windowNibName 
    112 { 
    113         self = [super initWithWindowNibName:windowNibName]; 
    114  
    115         return self; 
    116 } 
    117  
    118112- (void)dealloc 
    119113{ 
     114        //If we removed the account and info tab view items, we're currently also retaining them 
     115        if ([tabView_category indexOfTabViewItem:tabViewItem_info] == NSNotFound) { 
     116                [tabViewItem_accounts release]; tabViewItem_accounts = nil; 
     117                [tabViewItem_info release]; tabViewItem_info = nil; 
     118        } 
     119 
    120120        [displayedObject release]; displayedObject = nil; 
    121121        [loadedPanes release]; loadedPanes = nil; 
    122  
     122         
    123123        [super dealloc]; 
    124124} 
     
    238238{ 
    239239        if (tabView == tabView_category) { 
    240                 int     identifier = [[tabViewItem identifier] intValue]; 
    241  
    242                 //Take focus away from any controls to ensure that they register changes and save 
    243                 //      [[self window] makeFirstResponder:tabView_category]; 
    244                 [[self window] makeFirstResponder:nil]; 
     240                int                     identifier = [[tabViewItem identifier] intValue]; 
     241                NSArray         *panes = nil; 
     242 
     243                //Take focus away from any textual controls to ensure that they register changes and save 
     244                if ([[[self window] firstResponder] isKindOfClass:[NSText class]]) { 
     245                        [[self window] makeFirstResponder:nil]; 
     246                } 
    245247 
    246248                switch (identifier) { 
    247249                        case AIInfo_Profile: 
    248                                 [view_Profile setPanes:[self _panesInCategory:AIInfo_Profile]]; 
     250                                panes = [self _panesInCategory:AIInfo_Profile]; 
     251                                [view_Profile setPanes:panes]; 
    249252                                break; 
    250253                        case AIInfo_Accounts: 
    251                                 [view_Accounts setPanes:[self _panesInCategory:AIInfo_Accounts]]; 
     254                                panes = [self _panesInCategory:AIInfo_Accounts]; 
     255                                [view_Accounts setPanes:panes]; 
    252256                                break; 
    253257                        case AIInfo_Alerts: 
    254                                 [view_Alerts setPanes:[self _panesInCategory:AIInfo_Alerts]]; 
     258                                panes = [self _panesInCategory:AIInfo_Alerts]; 
     259                                [view_Alerts setPanes:panes]; 
    255260                                break; 
    256261                        case AIInfo_Settings: 
    257                                 [view_Settings setPanes:[self _panesInCategory:AIInfo_Settings]]; 
    258                                 break; 
    259                 } 
    260  
    261                 //Update the selected toolbar item (10.3 or higher) 
    262                 if ([[[self window] toolbar] respondsToSelector:@selector(setSelectedItemIdentifier:)]) { 
    263                         [[[self window] toolbar] setSelectedItemIdentifier:[tabViewItem identifier]]; 
     262                                panes = [self _panesInCategory:AIInfo_Settings]; 
     263                                [view_Settings setPanes:panes]; 
     264                                break; 
    264265                } 
    265266 
    266267                //Configure the loaded panes 
    267                 [self configurePanes]; 
     268                [self configurePanes:panes]; 
    268269        } 
    269270} 
     
    377378                                                                          [NSString stringWithFormat:AILocalizedString(@"%@'s Image",nil),[inObject displayName]] : 
    378379                                                                          AILocalizedString(@"Image Picker",nil))]; 
     380 
    379381                //Configure our subpanes 
    380                 [self configurePanes]; 
     382                [self configureVisiblityOfTabViewItemsForListObject:inObject]; 
    381383 
    382384                //Confiugre the drawer 
    383385                [self configureDrawer]; 
     386                 
     387                //Reconfigure the currently selected tab view item 
     388                [self tabView:tabView_category willSelectTabViewItem:[tabView_category selectedTabViewItem]]; 
     389 
    384390        } 
    385391} 
    386392 
    387393//Configure our views 
    388 - (void)configurePanes 
     394- (void)configurePanes:(NSArray *)panes 
    389395{ 
    390396        if (displayedObject) { 
    391                 NSEnumerator            *enumerator = [loadedPanes objectEnumerator]; 
     397                NSEnumerator            *enumerator = [panes objectEnumerator]; 
    392398                AIContactInfoPane       *pane; 
    393399 
     
    395401                        [pane configureForListObject:displayedObject]; 
    396402                } 
     403        } 
     404} 
     405 
     406- (void)configureVisiblityOfTabViewItemsForListObject:(AIListObject *)inObject 
     407{ 
     408        if ([inObject isKindOfClass:[AIListGroup class]]) { 
     409                //Remove the info and account items for groups 
     410                if ([tabView_category indexOfTabViewItem:tabViewItem_info] != NSNotFound) { 
     411                        [tabViewItem_accounts retain]; 
     412                        [tabViewItem_info retain]; 
     413                         
     414                        //Store the tab view item selected out of accounts or info, if one is selected 
     415                        NSTabViewItem *currentlySelected = [tabView_category selectedTabViewItem]; 
     416                        tabViewItem_lastSelectedForListContacts = ((currentlySelected == tabViewItem_accounts || currentlySelected == tabViewItem_info) ? 
     417                                                                                                           currentlySelected : 
     418                                                                                                           nil); 
     419 
     420                        [tabView_category removeTabViewItem:tabViewItem_accounts]; 
     421                        [tabView_category removeTabViewItem:tabViewItem_info]; 
     422                } 
     423                 
     424        } else { 
     425                //Add the info and account items back in if they are missing 
     426                if ([tabView_category indexOfTabViewItem:tabViewItem_info] == NSNotFound) { 
     427                        [tabView_category insertTabViewItem:tabViewItem_accounts atIndex:0]; 
     428                        [tabView_category insertTabViewItem:tabViewItem_info atIndex:0]; 
     429                         
     430                        //Restore the tab view item last selected for a contact if we have one stored 
     431                        if (tabViewItem_lastSelectedForListContacts) { 
     432                                [tabView_category selectTabViewItem:tabViewItem_lastSelectedForListContacts]; 
     433                                tabViewItem_lastSelectedForListContacts = nil; 
     434                        } 
     435                         
     436                        [tabViewItem_accounts release]; 
     437                        [tabViewItem_info release]; 
     438                }                        
    397439        } 
    398440}