2 // AIMessageHistoryPreferencesWindowController.m
5 // Created by Evan Schoenberg on 4/6/07.
8 #import "AIMessageHistoryPreferencesWindowController.h"
9 #import <Adium/AIPreferenceControllerProtocol.h>
12 AIMessageHistory_Always = 0,
13 AIMessageHistory_HaveTalkedInInterval,
14 AIMessageHistory_HaveNotTalkedInInterval
15 } AIMessageHistoryDisplayPref;
17 @implementation AIMessageHistoryPreferencesWindowController
19 * @brief Begin editing
21 * @param inAccount The account to edit
22 * @param parentWindow A window on which to show the edit account window as a sheet. If nil, account editing takes place in an independent window.
23 * @param notifyingTarget Target to notify when editing is complete.
25 + (void)configureMessageHistoryPreferencesOnWindow:(id)parentWindow
27 AIMessageHistoryPreferencesWindowController *controller;
29 controller = [[self alloc] initWithWindowNibName:@"MessageHistoryConfiguration"];
32 [NSApp beginSheet:[controller window]
33 modalForWindow:parentWindow
34 modalDelegate:controller
35 didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
38 [controller showWindow:nil];
44 //Observe preference changes
45 [[adium preferenceController] addObserver:self
46 forKeyPath:@"Message Context Display.Display Mode"
47 options:NSKeyValueObservingOptionNew
49 [self observeValueForKeyPath:@"Message Context Display.Display Mode"
50 ofObject:[adium preferenceController]
54 [super windowDidLoad];
57 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
59 BOOL enableTalkedControls = NO;
60 BOOL enableNotTalkedControls = NO;
62 switch ([[[adium preferenceController] preferenceForKey:@"Display Mode" group:@"Message Context Display"] intValue]) {
63 case AIMessageHistory_Always:
66 case AIMessageHistory_HaveTalkedInInterval:
67 enableTalkedControls = YES;
69 case AIMessageHistory_HaveNotTalkedInInterval:
70 enableNotTalkedControls = YES;
74 [textField_haveTalkedDays setEnabled:enableTalkedControls];
75 [stepper_haveTalkedDays setEnabled:enableTalkedControls];
76 [popUp_haveTalkedUnits setEnabled:enableTalkedControls];
78 [textField_haveNotTalkedDays setEnabled:enableNotTalkedControls];
79 [stepper_haveNotTalkedDays setEnabled:enableNotTalkedControls];
80 [popUp_haveNotTalkedUnits setEnabled:enableNotTalkedControls];
84 * @brief Window is closing
86 - (void)windowWillClose:(id)sender
88 [[adium preferenceController] removeObserver:self forKeyPath:@"Message Context Display.Display Mode"];
90 [super windowWillClose:sender];
95 * @brief Called as the user list edit sheet closes, dismisses the sheet
97 - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo