William Bowling is sharing code with you
Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.
Don't show this again1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | //
// AIAddressBookInspectorPane.m
// Adium
//
// Created by Elliott Harris on 1/17/08.
// Copyright 2008 Adium. All rights reserved.
//
#import "AIAddressBookInspectorPane.h"
#import <AIUtilities/AIStringAdditions.h>
#import <Adium/AIListObject.h>
#import <Adium/AIListContact.h>
#import <Adium/AIContactControllerProtocol.h>
#import <AIUtilities/AIDelayedTextField.h>
#define ADDRESS_BOOK_NIB_NAME (@"AIAddressBookInspectorPane")
@implementation AIAddressBookInspectorPane
- (id)init
{
if ((self = [super init])) {
[NSBundle loadNibNamed:[self nibName] owner:self];
[label_notes setLocalizedString:AILocalizedString(@"Notes:", "Label beside the field for contact notes in the Settings tab of the Get Info window")];
[button_chooseCard setLocalizedString:[AILocalizedStringFromTable(@"Choose Address Book Card", @"Buttons", "Button title to choose an Address Book card for a contact") stringByAppendingEllipsis]];
[label_abPeoplePickerChooseAnAddressCard setLocalizedString:AILocalizedString(@"Choose an Address Card:", nil)];
[button_abPeoplePickerOkay setLocalizedString:AILocalizedStringFromTable(@"Choose Card", @"Buttons", nil)];
[button_abPeoplePickerCancel setLocalizedString:AILocalizedStringFromTable(@"Cancel", @"Buttons", nil)];
}
return self;
}
- (void)dealloc
{
[inspectorContentView release]; inspectorContentView = nil;
[addressBookPanel release]; addressBookPanel = nil;
[super dealloc];
}
-(NSString *)nibName
{
return ADDRESS_BOOK_NIB_NAME;
}
-(NSView *)inspectorContentView
{
return inspectorContentView;
}
-(void)updateForListObject:(AIListObject *)inObject
{
NSString *currentNotes;
//Hold onto the object, using the highest-up metacontact if necessary
[displayedObject release];
displayedObject = ([inObject isKindOfClass:[AIListContact class]] ?
[(AIListContact *)inObject parentContact] :
inObject);
[displayedObject retain];
//Current note
if ((currentNotes = [displayedObject notes])) {
[contactNotes setStringValue:currentNotes];
} else {
[contactNotes setStringValue:@""];
}
}
- (IBAction)setNotes:(id)sender
{
if(!displayedObject)
return;
NSString *currentNote = [contactNotes stringValue];
[displayedObject setNotes:currentNote];
}
//Address Book Panel methods.
-(IBAction)runABPanel:(id)sender
{
[NSApp beginSheet:addressBookPanel
modalForWindow:[inspectorContentView window]
modalDelegate:self
didEndSelector:@selector(didEndSheet:returnCode:contextInfo:)
contextInfo:nil];
}
-(IBAction)cardSelected:(id)sender
{
//This method will be different during Adium integration, until then we simply print out some details about the ABPerson
//that has been selected. Pretty simple.
NSArray *selectedCards = [addressBookPicker selectedRecords];
if ([selectedCards count]) {
[(AIListContact *)displayedObject setAddressBookPerson:[selectedCards objectAtIndex:0]];
}
[NSApp endSheet:addressBookPanel];
}
-(IBAction)cancelABPanel:(id)sender
{
//This method simply ends the panel when the user clicks cancel.
[NSApp endSheet:addressBookPanel];
}
- (void)didEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
[addressBookPanel orderOut:self];
}
@end
|