libpurple.framework 2.3.1 as before but with HAVE_OPENSSL defined, which enables...
[adiumx.git] / Source / AIMessageHistoryPreferencesWindowController.m
blobd59c2ac7054f48ae3ecd89453ab38eb7bb8d517b
1 //
2 //  AIMessageHistoryPreferencesWindowController.m
3 //  Adium
4 //
5 //  Created by Evan Schoenberg on 4/6/07.
6 //
8 #import "AIMessageHistoryPreferencesWindowController.h"
9 #import <Adium/AIPreferenceControllerProtocol.h>
11 typedef enum {
12 AIMessageHistory_Always = 0,
13 AIMessageHistory_HaveTalkedInInterval,
14 AIMessageHistory_HaveNotTalkedInInterval
15 } AIMessageHistoryDisplayPref;
17 @implementation AIMessageHistoryPreferencesWindowController
18 /*!
19 * @brief Begin editing
20  *
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.
24  */
25 + (void)configureMessageHistoryPreferencesOnWindow:(id)parentWindow
27         AIMessageHistoryPreferencesWindowController     *controller;
28         
29         controller = [[self alloc] initWithWindowNibName:@"MessageHistoryConfiguration"];
31         if (parentWindow) {
32                 [NSApp beginSheet:[controller window]
33                    modalForWindow:parentWindow
34                         modalDelegate:controller
35                    didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
36                           contextInfo:nil];
37         } else {
38                 [controller showWindow:nil];
39         }
42 - (void)windowDidLoad
44         //Observe preference changes
45         [[adium preferenceController] addObserver:self
46                                                                    forKeyPath:@"Message Context Display.Display Mode"
47                                                                           options:NSKeyValueObservingOptionNew
48                                                                           context:NULL];
49         [self observeValueForKeyPath:@"Message Context Display.Display Mode"
50                                                 ofObject:[adium preferenceController]
51                                                   change:nil
52                                                  context:NULL];
53         
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;
61         
62         switch ([[[adium preferenceController] preferenceForKey:@"Display Mode" group:@"Message Context Display"] intValue]) {
63                 case AIMessageHistory_Always:
64                         break;
65                 
66                 case AIMessageHistory_HaveTalkedInInterval:
67                         enableTalkedControls = YES;
68                         break;
69                 case AIMessageHistory_HaveNotTalkedInInterval:
70                         enableNotTalkedControls = YES;
71                         break;
72         }
73         
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];
83 /*!
84  * @brief Window is closing
85  */
86 - (void)windowWillClose:(id)sender
88         [[adium preferenceController] removeObserver:self forKeyPath:@"Message Context Display.Display Mode"];
90         [super windowWillClose:sender];
91         [self autorelease];
94 /*!
95  * @brief Called as the user list edit sheet closes, dismisses the sheet
96  */
97 - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
99     [sheet orderOut:nil];
102 @end