-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInfoWindowController.m
72 lines (54 loc) · 2 KB
/
InfoWindowController.m
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
//
// InfoWindowController.m
// Mango
//
// Created by Juan Carlos Moreno on 4/17/14.
// Copyright (c) 2014 Juan Carlos Moreno. All rights reserved.
//
#import "InfoWindowController.h"
#import "CKCalendarView.h"
@interface InfoWindowController ()
@end
@implementation InfoWindowController
- (id)initWithWindow:(NSWindow *)window
{
self = [super initWithWindow:window];
if (self) {
// Initialization code here.
[self setRefreshRate:[NSNumber numberWithInt:5]];
[self setPulses:[NSNumber numberWithBool:YES]];
}
return self;
}
- (void)windowDidLoad
{
[super windowDidLoad];
///CGRect rect = NSRectToCGRect([[self cal] frame]);
//CKCalendarView *ckv = [[CKCalendarView alloc] initWithFrame: rect];
//[ckv setWantsLayer:YES];
//[ckv setTitleFont:[NSFont fontWithName:@"AvenirNext-DemiBold" size:15.0]];
//[ckv setDateOfWeekFont:[NSFont fontWithName:@"OpenSans-Regular" size:15.0]];
//[ckv setDateFont:[NSFont fontWithName:@"OpenSans-Light" size:13.0]];
//[[ckv layer] setBackgroundColor: [NSColor whiteColor].CGColor];
//[[self cal] addSubview:ckv];
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
}
-(void) getServerInfo
{
BOOL shouldRefresh = [[self pulses] boolValue];
float refreshRate = [[self refreshRate] floatValue];
if (shouldRefresh && refreshRate)
{
NSLog(@"Dispatching");
dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue());
dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, refreshRate * NSEC_PER_SEC, 2 * NSEC_PER_SEC);
dispatch_source_set_event_handler(timer, ^{
id json = [[[self dataManager] ConnectionManager] getServerStatus];
NSLog(@"%@", json);
});
dispatch_resume(timer);
}
// NSLog(@"Do I have a dataMGR %@", [self dataManager] );
//NSLog(@"%@", json);
}
@end