|
@@ -144,7 +144,7 @@
|
144
|
144
|
[self reloadListWithOptions];
|
145
|
145
|
}
|
146
|
146
|
|
147
|
|
--(void)openAndRemoveAndReloadWithIndex:(NSInteger)index Comments:(Boolean)comments {
|
|
147
|
+-(void)openAndRemoveAndReloadWithIndex:(NSInteger)index Comments:(Boolean)comments Both:(Boolean)both {
|
148
|
148
|
RedditItem *rItem = [redditItems objectAtIndex:index];
|
149
|
149
|
NSString *url;
|
150
|
150
|
if (comments)
|
|
@@ -152,6 +152,13 @@
|
152
|
152
|
else
|
153
|
153
|
url = [rItem link];
|
154
|
154
|
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
|
|
155
|
+ if (both) {
|
|
156
|
+ if (!comments)
|
|
157
|
+ url = [rItem comments];
|
|
158
|
+ else
|
|
159
|
+ url = [rItem link];
|
|
160
|
+ [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
|
|
161
|
+ }
|
155
|
162
|
|
156
|
163
|
if (currentState.removeVisited) {
|
157
|
164
|
// TODO remove selfpost, remove submenu if link & comments visited
|
|
@@ -172,12 +179,26 @@
|
172
|
179
|
|
173
|
180
|
-(IBAction)linkToOpen:(id)sender {
|
174
|
181
|
NSString *title = [(NSMenuItem *)sender title];
|
175
|
|
- if ([title isEqualToString:NSLocalizedString(@"Link...", nil)] || [title isEqualToString:NSLocalizedString(@"Comments...", nil)]) {
|
|
182
|
+ if ([title isEqualToString:NSLocalizedString(@"Link...", nil)] || [title isEqualToString:NSLocalizedString(@"Comments...", nil)] || [title isEqualToString:NSLocalizedString(@"Both", nil)]) {
|
176
|
183
|
for (NSUInteger i = 0; i < [menuItems count]; i++) {
|
177
|
184
|
NSMenuItem *item = [menuItems objectAtIndex:i];
|
178
|
185
|
NSMenu *submenu = item.submenu;
|
179
|
|
- if ((submenu != nil) && (sender == [submenu itemAtIndex:([title isEqualToString:NSLocalizedString(@"Link...", nil)] ? 0 : 1)])) {
|
180
|
|
- [self openAndRemoveAndReloadWithIndex:i Comments:[title isEqualToString:NSLocalizedString(@"Comments...", nil)]];
|
|
186
|
+ Boolean isComments = [title isEqualToString:NSLocalizedString(@"Comments...", nil)];
|
|
187
|
+ Boolean isBoth = [title isEqualToString:NSLocalizedString(@"Both", nil)];
|
|
188
|
+ if (isBoth) {
|
|
189
|
+ isComments = !isComments; // Open comments first, then link
|
|
190
|
+ }
|
|
191
|
+
|
|
192
|
+ NSInteger index;
|
|
193
|
+ if ([title isEqualToString:NSLocalizedString(@"Link...", nil)])
|
|
194
|
+ index = 0;
|
|
195
|
+ else if ([title isEqualToString:NSLocalizedString(@"Comments...", nil)])
|
|
196
|
+ index = 1;
|
|
197
|
+ else
|
|
198
|
+ index = 2;
|
|
199
|
+
|
|
200
|
+ if ((submenu != nil) && (sender == [submenu itemAtIndex:index])) {
|
|
201
|
+ [self openAndRemoveAndReloadWithIndex:i Comments:isComments Both:isBoth];
|
181
|
202
|
break;
|
182
|
203
|
}
|
183
|
204
|
}
|
|
@@ -185,7 +206,7 @@
|
185
|
206
|
for (NSUInteger i = 0; i < [menuItems count]; i++) {
|
186
|
207
|
NSMenuItem *item = [menuItems objectAtIndex:i];
|
187
|
208
|
if (sender == item) {
|
188
|
|
- [self openAndRemoveAndReloadWithIndex:i Comments:FALSE];
|
|
209
|
+ [self openAndRemoveAndReloadWithIndex:i Comments:FALSE Both:FALSE];
|
189
|
210
|
break;
|
190
|
211
|
}
|
191
|
212
|
}
|
|
@@ -228,6 +249,7 @@
|
228
|
249
|
NSMenu *submenu = [[NSMenu alloc] init];
|
229
|
250
|
[submenu addItemWithTitle:NSLocalizedString(@"Link...", @"Link item") action:@selector(linkToOpen:) keyEquivalent:@""];
|
230
|
251
|
[submenu addItemWithTitle:NSLocalizedString(@"Comments...", @"comment item") action:@selector(linkToOpen:) keyEquivalent:@""];
|
|
252
|
+ [submenu addItemWithTitle:NSLocalizedString(@"Both", @"Link & Comment item") action:@selector(linkToOpen:) keyEquivalent:@""];
|
231
|
253
|
[item setSubmenu:submenu];
|
232
|
254
|
}
|
233
|
255
|
return item;
|