-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathWCBookmarkController.m
109 lines (64 loc) · 1.78 KB
/
WCBookmarkController.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
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
//
// WCBookmarkController.m
// WiredClient
//
// Created by Rafaël Warnault on 26/06/13.
//
//
#import "WCBookmarkController.h"
#import "WCPreferences.h"
@interface WCBookmarkController (Private)
- (BOOL)_validate;
- (void)_bookmarkDidChange:(NSDictionary *)bookmark;
@end
@implementation WCBookmarkController (Private)
- (BOOL)_validate {
return ([[_bookmarksAddressTextField stringValue] length] > 0);
}
- (void)_bookmarkDidChange:(NSDictionary *)bookmark {
[[NSNotificationCenter defaultCenter] postNotificationName:WCBookmarkDidChangeNotification object:bookmark];
[[NSNotificationCenter defaultCenter] postNotificationName:WCBookmarksDidChangeNotification];
}
@end
@implementation WCBookmarkController
#pragma mark -
@synthesize bookmark = _bookmark;
#pragma mark -
- (void)dealloc
{
[_bookmark release];
[_oldBookmark release];
[_bookmarksPassword release];
[super dealloc];
}
#pragma mark -
- (void)setBookmark:(NSMutableDictionary *)bookmark {
if(_bookmark)
[_bookmark release]; _bookmark = nil;
if(_oldBookmark)
[_oldBookmark release]; _oldBookmark = nil;
_bookmark = [bookmark retain];
_oldBookmark = [bookmark copy];
}
#pragma mark -
- (void)reset {
[_bookmarksNameTextField setStringValue:@""];
[_bookmarksAddressTextField setStringValue:@""];
[_bookmarksLoginTextField setStringValue:@""];
[_bookmarksPasswordTextField setStringValue:@""];
[self setBookmark:nil];
[_bookmarksNameTextField becomeFirstResponder];
}
#pragma mark -
- (IBAction)ok:(id)sender {
if([self _validate]) {
[[WCSettings settings] synchronize];
[super ok:sender];
} else {
NSBeep();
}
}
- (IBAction)cancel:(id)sender {
[super cancel:sender];
}
@end