|
@@ -85,23 +85,16 @@
|
85
|
85
|
}
|
86
|
86
|
|
87
|
87
|
-(void)reloadListHasFrontpageCallback:(NSArray *)items {
|
88
|
|
- if (items == nil) {
|
89
|
|
- [firstMenuItem setTitle:NSLocalizedString(@"Error reading Frontpage!", @"Status api Read error")];
|
90
|
|
- [self clearMenuItems];
|
91
|
|
- [firstMenuItem setHidden:NO];
|
92
|
|
- return;
|
93
|
|
- }
|
94
|
|
- lastFullName = [items objectAtIndex:[items count] - 1]; // last link fullname is at end of array
|
95
|
|
- items = [items subarrayWithRange:NSMakeRange(0, [items count] - 1)]; // Remove last item
|
96
|
|
- redditItems = items;
|
97
|
|
- [self clearMenuItems];
|
98
|
|
- [firstMenuItem setHidden:YES];
|
99
|
|
- [self putItemArrayInMenu:redditItems];
|
|
88
|
+ [self reloadListHasXCallback:items ErrorMessage:NSLocalizedString(@"Error reading Frontpage!", @"Status api Read error")];
|
100
|
89
|
}
|
101
|
90
|
|
102
|
91
|
-(void)reloadListHasSubredditsCallback:(NSArray *)items {
|
|
92
|
+ [self reloadListHasXCallback:items ErrorMessage:NSLocalizedString(@"Error reading Subreddits!", @"Status api read error")];
|
|
93
|
+}
|
|
94
|
+
|
|
95
|
+-(void)reloadListHasXCallback:(NSArray *)items ErrorMessage:(NSString*)error {
|
103
|
96
|
if (items == nil) {
|
104
|
|
- [firstMenuItem setTitle:NSLocalizedString(@"Error reading Subreddits!", @"Status api read error")];
|
|
97
|
+ [firstMenuItem setTitle:error];
|
105
|
98
|
[self clearMenuItems];
|
106
|
99
|
[firstMenuItem setHidden:NO];
|
107
|
100
|
return;
|
|
@@ -198,26 +191,30 @@
|
198
|
191
|
-(void)putItemArrayInMenu:(NSArray *)array {
|
199
|
192
|
NSMutableArray *items = [NSMutableArray arrayWithCapacity:array.count];
|
200
|
193
|
for (NSUInteger i = 0; i < [array count]; i++) {
|
201
|
|
- RedditItem *reddit = [array objectAtIndex:i];
|
202
|
|
- NSMenuItem *item = [[NSMenuItem alloc] init];
|
203
|
|
- [item setTitle:reddit.name];
|
204
|
|
- if (![reddit.name isEqualToString:reddit.fullName])
|
205
|
|
- [item setToolTip:reddit.fullName];
|
206
|
|
- if (reddit.isSelf) {
|
207
|
|
- [item setAction:@selector(linkToOpen:)];
|
208
|
|
- [item setKeyEquivalent:@""];
|
209
|
|
- } else {
|
210
|
|
- NSMenu *submenu = [[NSMenu alloc] init];
|
211
|
|
- [submenu addItemWithTitle:NSLocalizedString(@"Link...", @"Link item") action:@selector(linkToOpen:) keyEquivalent:@""];
|
212
|
|
- [submenu addItemWithTitle:NSLocalizedString(@"Comments...", @"comment item") action:@selector(linkToOpen:) keyEquivalent:@""];
|
213
|
|
- [item setSubmenu:submenu];
|
214
|
|
- }
|
|
194
|
+ NSMenuItem *item = [self prepareItemForMenu:[array objectAtIndex:i]];
|
215
|
195
|
[items addObject:item];
|
216
|
196
|
[statusMenu insertItem:item atIndex:i];
|
217
|
197
|
}
|
218
|
198
|
menuItems = items;
|
219
|
199
|
}
|
220
|
200
|
|
|
201
|
+-(NSMenuItem *)prepareItemForMenu:(RedditItem *)reddit {
|
|
202
|
+ NSMenuItem *item = [[NSMenuItem alloc] init];
|
|
203
|
+ [item setTitle:reddit.name];
|
|
204
|
+ if (![reddit.name isEqualToString:reddit.fullName])
|
|
205
|
+ [item setToolTip:reddit.fullName];
|
|
206
|
+ if (reddit.isSelf) {
|
|
207
|
+ [item setAction:@selector(linkToOpen:)];
|
|
208
|
+ [item setKeyEquivalent:@""];
|
|
209
|
+ } else {
|
|
210
|
+ NSMenu *submenu = [[NSMenu alloc] init];
|
|
211
|
+ [submenu addItemWithTitle:NSLocalizedString(@"Link...", @"Link item") action:@selector(linkToOpen:) keyEquivalent:@""];
|
|
212
|
+ [submenu addItemWithTitle:NSLocalizedString(@"Comments...", @"comment item") action:@selector(linkToOpen:) keyEquivalent:@""];
|
|
213
|
+ [item setSubmenu:submenu];
|
|
214
|
+ }
|
|
215
|
+ return item;
|
|
216
|
+}
|
|
217
|
+
|
221
|
218
|
-(IBAction)showPreferences:(id)sender {
|
222
|
219
|
[NSApp activateIgnoringOtherApps:YES];
|
223
|
220
|
prefWindow = [[PrefController alloc] initWithWindowNibName:@"Prefs"];
|