-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTableController.m
More file actions
98 lines (72 loc) · 2.42 KB
/
TableController.m
File metadata and controls
98 lines (72 loc) · 2.42 KB
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
//
// TableController.m
// AXRecord
//
// Created by Sylvain Malacria on 15/02/16.
// Copyright © 2016 Sylvain Malacria. All rights reserved.
//
#import "TableController.h"
#import "AXElementTracker.h"
#import "AppTracker.h"
#import "WindowGrabber.h"
@implementation TableController{
AXElementTracker* elementTracker;
WindowTracker* windowTracker;
AppTracker* appTracker;
XMLFileAccessMethods* xmlFileAccess;
}
// main function
-(id)init{
self = [super init];
if(self){
[self refresh];
xmlFileAccess = [XMLFileAccessMethods new];
elementTracker = [[AXElementTracker alloc] initWithDelay:0.5 andXMLFileAccess:xmlFileAccess];
windowTracker = [[WindowTracker alloc] initWithDelay:0.2 andXMLFileAccess:xmlFileAccess];
[windowTracker setWindowTrackerDelegate:self];
appTracker= [[AppTracker alloc] initWithXMLFileAccess:xmlFileAccess];
}
return self;
}
-(void)refresh{
NSMutableArray* currSnaps = [NSMutableArray array];
for (VnrWindowInfo *info in [WindowGrabber getWindowList]) {
[currSnaps addObject:info];
}
self.snapshots = currSnaps;
//[self.tableView reloadData];
}
- (IBAction)doRefresh:(id)sender {
[self refresh];
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
return [self.snapshots count];
}
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
VnrWindowInfo *snapshot = [self.snapshots objectAtIndex:row];
NSString *identifier = [tableColumn identifier];
if([identifier isEqualToString:@"title"]) {
return snapshot.title;
} else if([identifier isEqualToString:@"ownerApplication"]) {
return snapshot.ownerName;
} /*else if([identifier isEqualToString:@"representedURL"]) {
return [[snapshot.representedURL URLByStandardizingPath] absoluteString];
}*/
return nil;
}
-(void)tableViewSelectionDidChange:(NSNotification *)notification
{
// NSInteger row = [self.windowTableView selectedRow];
// if(row >= 0) {
// windowView.selection = [windowView.snapshots objectAtIndex:row];
// } else {
// windowView.selection = nil;
// }
// [windowView setNeedsDisplay:YES];
}
-(void)windowInfoEventHappened:(WindowInfoEvent*)windowEvent{
[xmlFileAccess addXMLElementToFileForWindowEvent:windowEvent];
}
@end