| 1 |
#import "MainController.h" |
| 2 |
#import "MailBoxOutlineDataSource.h" |
| 3 |
#import "MainToolbarSource.h" |
| 4 |
#import "IconedCell.h" |
| 5 |
#import "ComposeToolbarSource.h" |
| 6 |
#import "PreferenceController.h" |
| 7 |
#import "DUMMailBoxManager.h" |
| 8 |
#import "MailBoxTableDataSource.h" |
| 9 |
#import "DUMMail.h" |
| 10 |
#import "DUMMailBox.h" |
| 11 |
#import "AddressBookController.h" |
| 12 |
@implementation MainController |
| 13 |
-(void)setupToolbar{ |
| 14 |
NSToolbar *toolbar; |
| 15 |
MainToolbarSource *mainToolbarSource; |
| 16 |
ComposeToolbarSource *composeToolbarSource; |
| 17 |
toolbar = [[NSToolbar alloc] initWithIdentifier:@"MainToolBar"]; |
| 18 |
mainToolbarSource = [[MainToolbarSource alloc] initWithController:self]; |
| 19 |
[toolbar setDelegate:mainToolbarSource]; |
| 20 |
[window setToolbar:toolbar]; |
| 21 |
[toolbar release]; |
| 22 |
|
| 23 |
toolbar = [[NSToolbar alloc] initWithIdentifier:@"ComposeToolBar"]; |
| 24 |
composeToolbarSource = [[ComposeToolbarSource alloc] initWithController:self]; |
| 25 |
[toolbar setDelegate:composeToolbarSource]; |
| 26 |
[composeWindow setToolbar:toolbar]; |
| 27 |
[toolbar release]; |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
-(void)awakeFromNib{ |
| 32 |
MailBoxOutlineDataSource *ds; |
| 33 |
NSButtonCell *mailCheckButtonCell; |
| 34 |
NSButtonCell *mailDeleteButtonCell; |
| 35 |
|
| 36 |
[window center]; |
| 37 |
|
| 38 |
mailBoxManager = [[DUMMailBoxManager alloc] init]; |
| 39 |
ds = [[MailBoxOutlineDataSource alloc] |
| 40 |
initWithMailBoxManager:mailBoxManager]; |
| 41 |
[folderTree setDataSource:ds]; |
| 42 |
|
| 43 |
[self setupToolbar]; |
| 44 |
|
| 45 |
|
| 46 |
mailCheckButtonCell = [[NSButtonCell alloc] init]; |
| 47 |
mailDeleteButtonCell = [[NSButtonCell alloc] init]; |
| 48 |
[mailCheckButtonCell setButtonType:NSSwitchButton]; |
| 49 |
[mailDeleteButtonCell setButtonType:NSSwitchButton]; |
| 50 |
|
| 51 |
[mailCheckButtonCell setTitle:@""]; |
| 52 |
[mailDeleteButtonCell setTitle:@""]; |
| 53 |
|
| 54 |
[[mailCheckTable tableColumnWithIdentifier:@"MailCheckFlag"] setDataCell:mailCheckButtonCell]; |
| 55 |
[[mailCheckTable tableColumnWithIdentifier:@"MailDeleteFlag"] setDataCell:mailDeleteButtonCell]; |
| 56 |
} |
| 57 |
-(void)dealloc{ |
| 58 |
[window release]; |
| 59 |
[composeWindow release]; |
| 60 |
[searchWindow release]; |
| 61 |
[mailList release]; |
| 62 |
[folderTree release]; |
| 63 |
[mailContents release]; |
| 64 |
[popServerTable release]; |
| 65 |
[smtpServerTable release]; |
| 66 |
[mailCheckTable release]; |
| 67 |
[mailBoxManager release]; |
| 68 |
[prefController release]; |
| 69 |
[addressbookController release]; |
| 70 |
[super dealloc]; |
| 71 |
} |
| 72 |
- (void)applicationDidFinishLaunching:(NSNotification*)notif |
| 73 |
{ |
| 74 |
NSTableColumn* tableColumn; |
| 75 |
IconedCell* iconedCell; |
| 76 |
// �t�H���_�c���[���A�A�C�R��+�������\���������������ACell�����X���s���B |
| 77 |
tableColumn = [folderTree tableColumnWithIdentifier:@"folderview"]; |
| 78 |
iconedCell = [[[IconedCell alloc] init] autorelease]; |
| 79 |
[tableColumn setDataCell:iconedCell]; |
| 80 |
} |
| 81 |
-(IBAction)createNewMessage:(id)sender{ |
| 82 |
[composeWindow makeKeyAndOrderFront:nil]; |
| 83 |
} |
| 84 |
-(IBAction)showPreference:(id)sender{ |
| 85 |
if(prefController == nil){ |
| 86 |
prefController = [[PreferenceController alloc] init]; |
| 87 |
} |
| 88 |
[prefController showWindow:self]; |
| 89 |
} |
| 90 |
-(IBAction)createRule:(id)sender{ |
| 91 |
[self showPreference:self]; |
| 92 |
[prefController selectPreferenceTabWithName:@"rule_tab"]; |
| 93 |
} |
| 94 |
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item{ |
| 95 |
MailBoxTableDataSource *ds; |
| 96 |
|
| 97 |
if([mailList dataSource] == nil){ |
| 98 |
ds = [[MailBoxTableDataSource alloc] initWithMailBox:item]; |
| 99 |
[mailList setDataSource:ds]; |
| 100 |
}else{ |
| 101 |
ds = [mailList dataSource]; |
| 102 |
[ds changeMailBox:item]; |
| 103 |
} |
| 104 |
[mailList reloadData]; |
| 105 |
return YES; |
| 106 |
} |
| 107 |
- (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(int)rowIndex{ |
| 108 |
MailBoxTableDataSource *ds; |
| 109 |
DUMMailBox *selectedMailBox; |
| 110 |
DUMMail *mail; |
| 111 |
NSString *text; |
| 112 |
|
| 113 |
ds = [aTableView dataSource]; |
| 114 |
selectedMailBox = [ds mailBox]; |
| 115 |
mail = [selectedMailBox mailAtIndex:rowIndex]; |
| 116 |
text = [mailContents string]; |
| 117 |
[mailContents replaceCharactersInRange:NSMakeRange(0, [text length]) |
| 118 |
withString:[mail content]]; |
| 119 |
[mail setIsUnread:NO]; |
| 120 |
[folderTree reloadData]; |
| 121 |
return YES; |
| 122 |
} |
| 123 |
-(IBAction)showAddressBook{ |
| 124 |
if(addressbookController == nil){ |
| 125 |
addressbookController |
| 126 |
= [[AddressBookController alloc] init]; |
| 127 |
} |
| 128 |
[addressbookController showWindow:self]; |
| 129 |
} |
| 130 |
@end |