This repository has been archived by the owner on Dec 3, 2018. It is now read-only.
forked from buzzfeed/Sketch-Toolbox
-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathSTPluginCellView.m
52 lines (44 loc) · 1.45 KB
/
STPluginCellView.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
//
// STPluginCellView.m
// Sketch Toolbox
//
// Created by Shahruz Shaukat on 5/19/14.
// Copyright (c) 2014 Shahruz Shaukat. All rights reserved.
//
#import "STPluginCellView.h"
#import "Plugin.h"
@implementation STPluginCellView
-(IBAction)actionButtonPressed:(NSButton*)sender {
if (!self.plugin.isInstalled) {
self.actionButton.enabled = NO;
[sender setTitle:NSLocalizedString(@"Downloading...",nil)];
[self.plugin download];
}
else [self.plugin delete];
}
-(void)infoButtonPressed:(id)sender {
[self openGitHubURL];
}
- (void)nameButtonPressed:(id)sender {
[self openGitHubURL];
}
-(void)populate {
self.nameButton.title = self.plugin.displayName;
self.descriptionField.stringValue = self.plugin.desc;
self.owner.stringValue = self.plugin.owner;
self.starCount.stringValue = [NSString stringWithFormat:@"%i", self.plugin.stars];
if (self.plugin.state == PluginStateInstalled) {
self.actionButton.enabled = YES;
[self.actionButton setTitle:NSLocalizedString(@"Uninstall",nil)];
} else if (self.plugin.state == PluginStateDownloading) {
self.actionButton.enabled = NO;
[self.actionButton setTitle:NSLocalizedString(@"Downloading...",nil)];
} else {
self.actionButton.enabled = YES;
[self.actionButton setTitle:NSLocalizedString(@"Install",nil)];
}
}
- (void)openGitHubURL {
[[NSWorkspace sharedWorkspace] openURL:self.plugin.repoURL];
}
@end