/
AppController.j
92 lines (74 loc) · 3.86 KB
/
AppController.j
1
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
/*
* AppController.j
* CappuccinoTalk
*
* Copyright (C) 2010 Ben Langfeld <ben@langfeld.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@import <Foundation/CPObject.j>
@import <Foundation/CPTimer.j>
@import "Controllers/ManageAccountsController.j"
@implementation AppController : CPObject
{
@outlet CPWindow theWindow; //this "outlet" is connected automatically by the Cib
@outlet CPSplitView mainSplitView;
@outlet CPButtonBar rosterButtonBar;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
// This is called when the application is done loading.
}
- (void)awakeFromCib
{
// This is called when the cib is done loading.
// You can implement this method on any object instantiated from a Cib.
// It's a useful hook for setting up current UI values, and other things.
[mainSplitView setButtonBar:rosterButtonBar forDividerAtIndex:0];
[mainSplitView setPosition:220 ofDividerAtIndex:0];
var plusButton = [CPButtonBar plusButton],
minusButton = [CPButtonBar minusButton],
manageAccountsButton = [CPButtonBar actionPopupButton];
[plusButton setTarget:[AccountsController sharedController]];
[plusButton setAction:@selector(promptForNewContact:)];
[minusButton setTarget:[AccountsController sharedController]];
[minusButton setAction:@selector(removeContact:)];
var manageAccountsItem = [[CPMenuItem alloc] initWithTitle:@"Manage Accounts" action:@selector(manageAccounts:) keyEquivalent:nil];
[manageAccountsItem setTarget:[AccountsController sharedController]];
var connectAccountsItem = [[CPMenuItem alloc] initWithTitle:@"Connect All Accounts" action:@selector(connectAllAccounts:) keyEquivalent:nil];
[connectAccountsItem setTarget:[AccountsController sharedController]];
var disconnectAccountsItem = [[CPMenuItem alloc] initWithTitle:@"Disconnect All Accounts" action:@selector(disconnectAllAccounts:) keyEquivalent:nil];
[disconnectAccountsItem setTarget:[AccountsController sharedController]];
var connectSelectedAccountItem = [[CPMenuItem alloc] initWithTitle:@"Connect Selected Account" action:@selector(connectSelectedAccount:) keyEquivalent:nil];
[connectSelectedAccountItem setTarget:[AccountsController sharedController]];
var disconnectSelectedAccountItem = [[CPMenuItem alloc] initWithTitle:@"Disconnect Selected Account" action:@selector(disconnectSelectedAccount:) keyEquivalent:nil];
[disconnectSelectedAccountItem setTarget:[AccountsController sharedController]];
[manageAccountsButton addItem:connectSelectedAccountItem];
[manageAccountsButton addItem:disconnectSelectedAccountItem];
[manageAccountsButton addItem:[CPMenuItem separatorItem]];
[manageAccountsButton addItem:connectAccountsItem];
[manageAccountsButton addItem:disconnectAccountsItem];
[manageAccountsButton addItem:[CPMenuItem separatorItem]];
[manageAccountsButton addItem:manageAccountsItem];
[rosterButtonBar setButtons:[plusButton, minusButton, manageAccountsButton]];
}
- (CGFloat)splitView:(CPSplitView)splitView constrainMinCoordinate:(float)proposedMin ofSubviewAt:(int)dividerIndex
{
return 160;
}
- (CGFloat)splitView:(CPSplitView)splitView constrainMaxCoordinate:(float)proposedMax ofSubviewAt:(int)dividerIndex
{
return 300;
}
@end