-
Notifications
You must be signed in to change notification settings - Fork 5
/
AppController.j
187 lines (152 loc) · 6.04 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*
* AppController.j
* GithubIssues
*
* Created by Randy Luecke on April 14, 2011.
* Copyright 2011, RCLConcepts, LLC All rights reserved.
*/
@import <Foundation/CPObject.j>
@import "ISSideBar.j"
@import "ISToolBar.j"
@import "ISAccountView.j"
@import "ISRepositoriesController.j"
@import "ISSourceListDataView.j"
@import "ISRepository.j"
@import "ISSortBar.j"
@import "ISIssuesController.j"
@import "CPWindow+animations.j"
@import "ISGithubAPIController.j"
@import "ISWindow.j"
@import "ISIssueDataView.j"
@import "ISModel.j"
@import "ISLoadingIndicator.j"
@import "LPMultiLineTextField.j"
@import "ISNewIssueWindowController.j"
@import "ISNewLabelWindowController.j"
@import "ISLabel.j"
@import "ISIssue.j"
@import "CPDate+extentions.j"
@implementation AppController : CPObject
{
@outlet CPWindow theWindow;
@outlet ISToolbar toolbar @accessors(readonly);
@outlet ISSideBar sidebar;
@outlet CPView mainContentView;
@outlet CPSplitView verticalSplitView;
@outlet ISRepositoriesController reposController @accessors(readonly);
@outlet ISModel model @accessors;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
// This is called when the application is done loading.
[CPMenu setMenuBarVisible:NO];
// try to login
var defaults = [CPUserDefaults standardUserDefaults],
user = [defaults objectForKey:"username"],
pass = [defaults objectForKey:"password"],
apicontroller = [ISGithubAPIController sharedController];
if (user && pass)
{
[apicontroller setUsername:user];
[apicontroller setPassword:pass];
[apicontroller authenticateWithCallback:nil];
}
// FIX ME: parse the url arguments
// Load any saved settings.
[model load];
}
- (void)awakeFromCib
{
// FIX ME: Xcode 4 wont let me do this... wtfbbq
[mainContentView setAutoresizingMask:CPViewWidthSizable];
if ([CPPlatform isBrowser])
// In this case, we want the window from Cib to become our full browser window
[theWindow setFullPlatformWindow:YES];
else
{
// FIX ME: make this a sexy ISWindow style window
var contentView = [theWindow contentView];
theWindow = [[ISWindow alloc] initWithContentRect:CGRectMake(50, 50, 1000, 670) styleMask:nil];
[contentView setFrame:CGRectMake(15,45,920,640)];
[[theWindow contentView] addSubview:contentView];
[theWindow orderFront:self];
}
[mainContentView setBackgroundColor:[CPColor colorWithPatternImage:resourcesImage("MainContentTexture.png", 164, 141)]];
// we want to know when the source list changes size so we can update the toolbar tabs
[sidebar setPostsFrameChangedNotifications:YES];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(sourceListDidResize:) name:CPViewFrameDidChangeNotification object:sidebar];
// Special split view styling.
// FIX ME: get the rbga values here
[verticalSplitView setValue:[CPColor colorWithHexString:"80878d"] forThemeAttribute:"pane-divider-color"];
// To the right of the split view there is a 1px 0.25 alpha white line, but we can't make it part of the splitter
// itself because it actually overlaps the lines and widgets on the right side. Instead, make a transparent
// overlay view.
var rightOfSplitterWhitenessView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 1, [mainContentView bounds].size.height)];
[rightOfSplitterWhitenessView setAutoresizingMask:CPViewHeightSizable | CPViewMaxXMargin];
[rightOfSplitterWhitenessView setBackgroundColor:[CPColor colorWithCSSString:"rgba(255, 255, 255, 0.267)"]];
// XXX This view must always be above all other views in the main content area.
[mainContentView addSubview:rightOfSplitterWhitenessView];
}
- (@action)newRepo:(id)aSender
{
[[ISNewRepoWindow sharedWindow] showWindow:aSender];
}
- (@action)newIssue:(id)sender
{
var newIssueWindow = [[ISNewIssueWindowController alloc] initWithWindowCibName:"NewIssueWindow"];
[newIssueWindow setRepos:[reposController arrangedObjects]];
[newIssueWindow showWindow:sender];
[newIssueWindow selectRepo:[reposController selectedObjects][0]];
}
// Main splitview delegates
- (void)sourceListDidResize:(CPNotification)aNote
{
// As the splitview resizes
// we need to reposition the tab view thingy at the top...
// plus a couple to take the splitview divider into account...
var point = [[aNote object] frameSize].width + 2;
[toolbar splitViewMovedTo:point];
}
- (float)splitView:(CPSplitView)aSplitView constrainMinCoordinate:(float)proposedMin ofSubviewAt:(int)subviewIndex
{
return 210;
}
- (float)splitView:(CPSplitView)aSplitView constrainMaxCoordinate:(float)proposedMin ofSubviewAt:(int)subviewIndex
{
return 300;
}
@end
#pragma mark hello world
/*!
FIX ME:
Make this more awesome
*/
@implementation ISScroller : CPScroller
- (id)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
if(self)
{
var scrollerColor = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices:[
resourcesImage("scroller_top.png", 11, 6),
resourcesImage("scroller_mid.png", 11, 9),
resourcesImage("scroller_bot.png", 11, 6)
] isVertical:YES]];
var bgColor = [CPColor clearColor];
[self setValue:scrollerColor forThemeAttribute:"knob-color"];
[self setValue:bgColor forThemeAttribute:"knob-slot-color"];
[self setValue:bgColor forThemeAttribute:"increment-line-color"];
[self setValue:bgColor forThemeAttribute:"decrement-line-color"];
[self setValue:CGSizeMake(11,5) forThemeAttribute:"decrement-line-size"];
[self setValue:CGSizeMake(11,5) forThemeAttribute:"increment-line-size"];
}
return self;
}
@end
/*!
We're going to define a nice global helper function to load images from the main bundle.
*/
resourcesImage = function(path, width, height)
{
return [[CPImage alloc] initByReferencingFile:[[CPBundle mainBundle] pathForResource:path] size:CGSizeMake(width, height)];
}