Browse Source

Can show subreddit name behind title.

Bugfix: Saving preferences reloads from start instead of current position
Thomas Buck 10 years ago
parent
commit
a3b4d503ec

+ 1
- 1
RedditBar/AppDelegate.h View File

59
 -(void)reloadListHasSubredditsCallback:(NSArray *)items;
59
 -(void)reloadListHasSubredditsCallback:(NSArray *)items;
60
 -(void)reloadListHasFrontpageCallback:(NSArray *)items;
60
 -(void)reloadListHasFrontpageCallback:(NSArray *)items;
61
 
61
 
62
--(void)prefReturnName:(NSString *)name Modhash:(NSString *)modhash subscriptions:(Boolean)subscriptions subreddits:(NSString *)subreddits length:(NSInteger)length;
62
+-(void)prefReturnName:(NSString *)name Modhash:(NSString *)modhash subscriptions:(Boolean)subscriptions subreddits:(NSString *)subreddits length:(NSInteger)length printSubs:(Boolean)showSubreddits;
63
 
63
 
64
 @end
64
 @end

+ 7
- 2
RedditBar/AppDelegate.m View File

42
     [statusItem setMenu:statusMenu];
42
     [statusItem setMenu:statusMenu];
43
     [statusItem setToolTip:NSLocalizedString(@"RedditBar", @"Main Menuitem Tooltip")];
43
     [statusItem setToolTip:NSLocalizedString(@"RedditBar", @"Main Menuitem Tooltip")];
44
     [statusItem setHighlightMode:YES];
44
     [statusItem setHighlightMode:YES];
45
-    lastFullName = nil;
46
     currentState = [[StateModel alloc] init];
45
     currentState = [[StateModel alloc] init];
47
     [self defaultPreferences];
46
     [self defaultPreferences];
48
     [self loadPreferences];
47
     [self loadPreferences];
48
+    lastFullName = nil;
49
     [self reloadListWithOptions];
49
     [self reloadListWithOptions];
50
 }
50
 }
51
 
51
 
55
     [appDefaults setValue:@"" forKey:@"modhash"];
55
     [appDefaults setValue:@"" forKey:@"modhash"];
56
     [appDefaults setValue:[NSNumber numberWithBool:YES] forKey:@"subscriptions"];
56
     [appDefaults setValue:[NSNumber numberWithBool:YES] forKey:@"subscriptions"];
57
     [appDefaults setValue:[NSNumber numberWithInt:10] forKey:@"length"];
57
     [appDefaults setValue:[NSNumber numberWithInt:10] forKey:@"length"];
58
+    [appDefaults setValue:[NSNumber numberWithBool:YES] forKey:@"showSubs"];
58
     [store registerDefaults:appDefaults];
59
     [store registerDefaults:appDefaults];
59
 }
60
 }
60
 
61
 
65
     [store setBool:currentState.useSubscriptions forKey:@"subscriptions"];
66
     [store setBool:currentState.useSubscriptions forKey:@"subscriptions"];
66
     [store setObject:currentState.subreddits forKey:@"subreddits"];
67
     [store setObject:currentState.subreddits forKey:@"subreddits"];
67
     [store setInteger:currentState.length forKey:@"length"];
68
     [store setInteger:currentState.length forKey:@"length"];
69
+    [store setBool:currentState.showSubreddit forKey:@"showSubs"];
68
     [store synchronize];
70
     [store synchronize];
69
 }
71
 }
70
 
72
 
76
     [currentState setUseSubscriptions:[store boolForKey:@"subscriptions"]];
78
     [currentState setUseSubscriptions:[store boolForKey:@"subscriptions"]];
77
     [currentState setSubreddits:[store arrayForKey:@"subreddits"]];
79
     [currentState setSubreddits:[store arrayForKey:@"subreddits"]];
78
     [currentState setLength:[store integerForKey:@"length"]];
80
     [currentState setLength:[store integerForKey:@"length"]];
81
+    [currentState setShowSubreddit:[store boolForKey:@"showSubs"]];
79
 }
82
 }
80
 
83
 
81
 -(void)reloadListNotAuthenticatedCallback {
84
 -(void)reloadListNotAuthenticatedCallback {
228
     [application orderFrontStandardAboutPanel:self];
231
     [application orderFrontStandardAboutPanel:self];
229
 }
232
 }
230
 
233
 
231
--(void)prefReturnName:(NSString *)name Modhash:(NSString *)modhash subscriptions:(Boolean)subscriptions subreddits:(NSString *)subreddits length:(NSInteger)length {
234
+-(void)prefReturnName:(NSString *)name Modhash:(NSString *)modhash subscriptions:(Boolean)subscriptions subreddits:(NSString *)subreddits length:(NSInteger)length printSubs:(Boolean)showSubreddits {
232
     currentState.username = name;
235
     currentState.username = name;
233
     currentState.modhash = modhash;
236
     currentState.modhash = modhash;
234
     currentState.useSubscriptions = subscriptions;
237
     currentState.useSubscriptions = subscriptions;
235
     currentState.subreddits = [subreddits componentsSeparatedByString: @"\n"];
238
     currentState.subreddits = [subreddits componentsSeparatedByString: @"\n"];
236
     currentState.length = length;
239
     currentState.length = length;
240
+    currentState.showSubreddit = showSubreddits;
237
     [self savePreferences];
241
     [self savePreferences];
242
+    lastFullName = nil; // reload from start
238
     [self reloadListWithOptions];
243
     [self reloadListWithOptions];
239
 }
244
 }
240
 
245
 

+ 3
- 6
RedditBar/Base.lproj/Prefs.strings View File

8
 /* Class = "NSMenuItem"; title = "Cut"; ObjectID = "32T-3T-EcY"; */
8
 /* Class = "NSMenuItem"; title = "Cut"; ObjectID = "32T-3T-EcY"; */
9
 "32T-3T-EcY.title" = "Cut";
9
 "32T-3T-EcY.title" = "Cut";
10
 
10
 
11
-/* Class = "NSTextFieldCell"; title = "Subreddits:"; ObjectID = "Cmr-7n-CaG"; */
12
-"Cmr-7n-CaG.title" = "Subreddits:";
13
-
14
 /* Class = "NSTextFieldCell"; title = "Items:"; ObjectID = "FNJ-RL-DXT"; */
11
 /* Class = "NSTextFieldCell"; title = "Items:"; ObjectID = "FNJ-RL-DXT"; */
15
 "FNJ-RL-DXT.title" = "Items:";
12
 "FNJ-RL-DXT.title" = "Items:";
16
 
13
 
41
 /* Class = "NSTextFieldCell"; title = "Password:"; ObjectID = "m11-YF-fEa"; */
38
 /* Class = "NSTextFieldCell"; title = "Password:"; ObjectID = "m11-YF-fEa"; */
42
 "m11-YF-fEa.title" = "Password:";
39
 "m11-YF-fEa.title" = "Password:";
43
 
40
 
41
+/* Class = "NSButtonCell"; title = "Show Subreddit after Title"; ObjectID = "nFK-xi-2F3"; */
42
+"nFK-xi-2F3.title" = "Show Subreddit after Title";
43
+
44
 /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "qSu-ha-DhM"; */
44
 /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "qSu-ha-DhM"; */
45
 "qSu-ha-DhM.title" = "Select All";
45
 "qSu-ha-DhM.title" = "Select All";
46
 
46
 
47
-/* Class = "NSButtonCell"; title = "Subscriptions"; ObjectID = "vW5-Cp-Bm1"; */
48
-"vW5-Cp-Bm1.title" = "Subscriptions";
49
-
50
 /* Class = "NSMenuItem"; title = "Copy"; ObjectID = "wSY-To-FDI"; */
47
 /* Class = "NSMenuItem"; title = "Copy"; ObjectID = "wSY-To-FDI"; */
51
 "wSY-To-FDI.title" = "Copy";
48
 "wSY-To-FDI.title" = "Copy";

+ 21
- 21
RedditBar/Base.lproj/Prefs.xib View File

12
                 <outlet property="lengthStepper" destination="jxz-fQ-M1L" id="NK5-G4-9UJ"/>
12
                 <outlet property="lengthStepper" destination="jxz-fQ-M1L" id="NK5-G4-9UJ"/>
13
                 <outlet property="password" destination="ARP-lb-J16" id="EDd-om-ciF"/>
13
                 <outlet property="password" destination="ARP-lb-J16" id="EDd-om-ciF"/>
14
                 <outlet property="progress" destination="vz0-tR-n1f" id="t06-dO-WKY"/>
14
                 <outlet property="progress" destination="vz0-tR-n1f" id="t06-dO-WKY"/>
15
+                <outlet property="showSubreddit" destination="fRR-M9-szp" id="bGR-ej-R9R"/>
15
                 <outlet property="subreddits" destination="EhP-FS-8dT" id="td1-kv-jQm"/>
16
                 <outlet property="subreddits" destination="EhP-FS-8dT" id="td1-kv-jQm"/>
16
                 <outlet property="subscriptions" destination="vW5-Cp-Bm1" id="gja-K0-7Uh"/>
17
                 <outlet property="subscriptions" destination="vW5-Cp-Bm1" id="gja-K0-7Uh"/>
17
                 <outlet property="username" destination="0mi-88-o94" id="4bB-K2-q5m"/>
18
                 <outlet property="username" destination="0mi-88-o94" id="4bB-K2-q5m"/>
57
                         </textFieldCell>
58
                         </textFieldCell>
58
                     </textField>
59
                     </textField>
59
                     <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="qFP-pd-32c">
60
                     <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="qFP-pd-32c">
60
-                        <rect key="frame" x="18" y="52" width="96" height="17"/>
61
+                        <rect key="frame" x="18" y="104" width="96" height="17"/>
61
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
62
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
62
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Items:" id="FNJ-RL-DXT">
63
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Items:" id="FNJ-RL-DXT">
63
                             <font key="font" metaFont="system"/>
64
                             <font key="font" metaFont="system"/>
102
                             <action selector="performClose:" target="1" id="A62-EW-ZrT"/>
103
                             <action selector="performClose:" target="1" id="A62-EW-ZrT"/>
103
                         </connections>
104
                         </connections>
104
                     </button>
105
                     </button>
105
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="R9P-ZH-hHZ">
106
-                        <rect key="frame" x="18" y="235" width="96" height="17"/>
107
-                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
108
-                        <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Subreddits:" id="Cmr-7n-CaG">
109
-                            <font key="font" metaFont="system"/>
110
-                            <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
111
-                            <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
112
-                        </textFieldCell>
113
-                    </textField>
114
                     <scrollView horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" id="8ew-wY-1Yh">
106
                     <scrollView horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" id="8ew-wY-1Yh">
115
-                        <rect key="frame" x="20" y="79" width="300" height="150"/>
107
+                        <rect key="frame" x="20" y="129" width="300" height="100"/>
116
                         <autoresizingMask key="autoresizingMask"/>
108
                         <autoresizingMask key="autoresizingMask"/>
117
                         <clipView key="contentView" copiesOnScroll="NO" id="ENU-Jw-8fO">
109
                         <clipView key="contentView" copiesOnScroll="NO" id="ENU-Jw-8fO">
118
-                            <rect key="frame" x="1" y="1" width="298" height="148"/>
110
+                            <rect key="frame" x="1" y="1" width="298" height="98"/>
119
                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
111
                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
120
                             <subviews>
112
                             <subviews>
121
                                 <textView editable="NO" importsGraphics="NO" richText="NO" findStyle="panel" allowsUndo="YES" verticallyResizable="YES" allowsNonContiguousLayout="YES" id="EhP-FS-8dT">
113
                                 <textView editable="NO" importsGraphics="NO" richText="NO" findStyle="panel" allowsUndo="YES" verticallyResizable="YES" allowsNonContiguousLayout="YES" id="EhP-FS-8dT">
122
-                                    <rect key="frame" x="0.0" y="0.0" width="298" height="148"/>
114
+                                    <rect key="frame" x="0.0" y="0.0" width="298" height="98"/>
123
                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
115
                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
124
                                     <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
116
                                     <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
125
-                                    <size key="minSize" width="298" height="148"/>
117
+                                    <size key="minSize" width="298" height="98"/>
126
                                     <size key="maxSize" width="463" height="10000000"/>
118
                                     <size key="maxSize" width="463" height="10000000"/>
127
                                     <color key="insertionPointColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
119
                                     <color key="insertionPointColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
128
-                                    <size key="minSize" width="298" height="148"/>
120
+                                    <size key="minSize" width="298" height="98"/>
129
                                     <size key="maxSize" width="463" height="10000000"/>
121
                                     <size key="maxSize" width="463" height="10000000"/>
130
                                 </textView>
122
                                 </textView>
131
                             </subviews>
123
                             </subviews>
136
                             <autoresizingMask key="autoresizingMask"/>
128
                             <autoresizingMask key="autoresizingMask"/>
137
                         </scroller>
129
                         </scroller>
138
                         <scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="z7j-r6-B6f">
130
                         <scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="z7j-r6-B6f">
139
-                            <rect key="frame" x="283" y="1" width="16" height="148"/>
131
+                            <rect key="frame" x="283" y="1" width="16" height="98"/>
140
                             <autoresizingMask key="autoresizingMask"/>
132
                             <autoresizingMask key="autoresizingMask"/>
141
                         </scroller>
133
                         </scroller>
142
                     </scrollView>
134
                     </scrollView>
143
                     <button id="XZM-90-hQ8">
135
                     <button id="XZM-90-hQ8">
144
-                        <rect key="frame" x="118" y="234" width="204" height="18"/>
136
+                        <rect key="frame" x="18" y="236" width="280" height="25"/>
145
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
137
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
146
-                        <buttonCell key="cell" type="check" title="Subscriptions" bezelStyle="regularSquare" imagePosition="overlaps" alignment="right" state="on" inset="2" id="vW5-Cp-Bm1">
138
+                        <buttonCell key="cell" type="check" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="vW5-Cp-Bm1">
147
                             <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
139
                             <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
148
                             <font key="font" metaFont="system"/>
140
                             <font key="font" metaFont="system"/>
149
                         </buttonCell>
141
                         </buttonCell>
152
                         </connections>
144
                         </connections>
153
                     </button>
145
                     </button>
154
                     <textField verticalHuggingPriority="750" id="MAv-jO-hIv">
146
                     <textField verticalHuggingPriority="750" id="MAv-jO-hIv">
155
-                        <rect key="frame" x="120" y="49" width="57" height="22"/>
147
+                        <rect key="frame" x="120" y="99" width="57" height="22"/>
156
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
148
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
157
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="right" title="10" drawsBackground="YES" id="0SD-Tf-uZS">
149
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="right" title="10" drawsBackground="YES" id="0SD-Tf-uZS">
158
                             <font key="font" metaFont="system"/>
150
                             <font key="font" metaFont="system"/>
165
                         </connections>
157
                         </connections>
166
                     </textField>
158
                     </textField>
167
                     <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" id="jxz-fQ-M1L">
159
                     <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" id="jxz-fQ-M1L">
168
-                        <rect key="frame" x="182" y="46" width="19" height="27"/>
160
+                        <rect key="frame" x="182" y="96" width="19" height="27"/>
169
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
161
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
170
                         <stepperCell key="cell" continuous="YES" alignment="left" maxValue="100" id="Gba-jV-Ouh"/>
162
                         <stepperCell key="cell" continuous="YES" alignment="left" maxValue="100" id="Gba-jV-Ouh"/>
171
                         <connections>
163
                         <connections>
173
                         </connections>
165
                         </connections>
174
                     </stepper>
166
                     </stepper>
175
                     <progressIndicator canDrawConcurrently="YES" horizontalHuggingPriority="750" verticalHuggingPriority="750" maxValue="100" displayedWhenStopped="NO" bezeled="NO" indeterminate="YES" controlSize="small" style="spinning" id="vz0-tR-n1f">
167
                     <progressIndicator canDrawConcurrently="YES" horizontalHuggingPriority="750" verticalHuggingPriority="750" maxValue="100" displayedWhenStopped="NO" bezeled="NO" indeterminate="YES" controlSize="small" style="spinning" id="vz0-tR-n1f">
176
-                        <rect key="frame" x="267" y="49" width="16" height="16"/>
168
+                        <rect key="frame" x="304" y="240" width="16" height="16"/>
177
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
169
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
178
                     </progressIndicator>
170
                     </progressIndicator>
171
+                    <button id="fRR-M9-szp">
172
+                        <rect key="frame" x="18" y="75" width="304" height="18"/>
173
+                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
174
+                        <buttonCell key="cell" type="check" title="Show Subreddit after Title" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="nFK-xi-2F3">
175
+                            <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
176
+                            <font key="font" metaFont="system"/>
177
+                        </buttonCell>
178
+                    </button>
179
                 </subviews>
179
                 </subviews>
180
             </view>
180
             </view>
181
         </window>
181
         </window>

+ 1
- 0
RedditBar/PrefController.h View File

40
 @property (atomic, retain) IBOutlet NSTextField *lengthField;
40
 @property (atomic, retain) IBOutlet NSTextField *lengthField;
41
 @property (atomic, retain) IBOutlet NSStepper *lengthStepper;
41
 @property (atomic, retain) IBOutlet NSStepper *lengthStepper;
42
 @property (atomic, retain) IBOutlet NSProgressIndicator *progress;
42
 @property (atomic, retain) IBOutlet NSProgressIndicator *progress;
43
+@property (weak) IBOutlet NSButton *showSubreddit;
43
 @property (atomic, retain) NSObject *parent;
44
 @property (atomic, retain) NSObject *parent;
44
 @property (atomic, retain) StateModel *state;
45
 @property (atomic, retain) StateModel *state;
45
 @property (atomic) NSInteger length;
46
 @property (atomic) NSInteger length;

+ 10
- 2
RedditBar/PrefController.m View File

34
 NSString *modhashSetLiteral = @"__MODHASH__IS__SET__";
34
 NSString *modhashSetLiteral = @"__MODHASH__IS__SET__";
35
 NSString *subredditCharacters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_\n";
35
 NSString *subredditCharacters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_\n";
36
 
36
 
37
-@synthesize username, password, subscriptions, subreddits, win, parent, state, lengthFormat, lengthField, lengthStepper, length, progress;
37
+@synthesize username, password, subscriptions, subreddits, win, parent, state, lengthFormat, lengthField, lengthStepper, length, progress, showSubreddit;
38
 
38
 
39
 -(Boolean)isValidList:(NSString *)input {
39
 -(Boolean)isValidList:(NSString *)input {
40
     NSCharacterSet *invalidChars = [[NSCharacterSet characterSetWithCharactersInString:subredditCharacters] invertedSet];
40
     NSCharacterSet *invalidChars = [[NSCharacterSet characterSetWithCharactersInString:subredditCharacters] invertedSet];
63
     [lengthStepper setIntegerValue:length];
63
     [lengthStepper setIntegerValue:length];
64
     [lengthField setIntegerValue:length];
64
     [lengthField setIntegerValue:length];
65
     [progress setUsesThreadedAnimation:YES];
65
     [progress setUsesThreadedAnimation:YES];
66
+    [showSubreddit setState:[NSNumber numberWithBool:state.showSubreddit].integerValue];
66
 }
67
 }
67
 
68
 
68
 -(IBAction)buttonSave:(id)sender {
69
 -(IBAction)buttonSave:(id)sender {
118
             return;
119
             return;
119
         }
120
         }
120
     }
121
     }
122
+    Boolean print;
123
+    if (showSubreddit.state != 0)
124
+        print = TRUE;
125
+    else
126
+        print = FALSE;
121
     
127
     
122
     AppDelegate *app = (AppDelegate *)parent;
128
     AppDelegate *app = (AppDelegate *)parent;
123
-    [app prefReturnName:username.stringValue Modhash:modhash subscriptions:subs subreddits:subreddits.textStorage.string length:length];
129
+    [app prefReturnName:username.stringValue Modhash:modhash subscriptions:subs subreddits:subreddits.textStorage.string length:length printSubs:print];
124
     [win performClose:self];
130
     [win performClose:self];
125
 }
131
 }
126
 
132
 
127
 -(IBAction)toggleSubs:(id)sender {
133
 -(IBAction)toggleSubs:(id)sender {
128
     if (subscriptions.state != 0) {
134
     if (subscriptions.state != 0) {
129
         [subreddits setEditable:FALSE];
135
         [subreddits setEditable:FALSE];
136
+        [subscriptions setTitle:NSLocalizedString(@"Use Subscriptions", @"Pref Checkbox State 1")];
130
     } else {
137
     } else {
131
         [subreddits setEditable:TRUE];
138
         [subreddits setEditable:TRUE];
139
+        [subscriptions setTitle:NSLocalizedString(@"Use Subreddits list", @"Pref Checkbox State 0")];
132
     }
140
     }
133
 }
141
 }
134
 
142
 

+ 17
- 7
RedditBar/Reddit.m View File

31
 
31
 
32
 @implementation Reddit
32
 @implementation Reddit
33
 
33
 
34
-NSInteger maxTitleLength = 50;
34
+NSInteger maxTitleLength = 60;
35
 NSString *replaceTextForTitle = @"...";
35
 NSString *replaceTextForTitle = @"...";
36
+NSString *subredditFormat = @" [r/%@]";
36
 #define AUTHOR @"xythobuz"
37
 #define AUTHOR @"xythobuz"
37
 
38
 
38
 @synthesize username, modhash, password, version, appName, author, length, subreddits;
39
 @synthesize username, modhash, password, version, appName, author, length, subreddits;
99
     }
100
     }
100
 }
101
 }
101
 
102
 
102
--(NSArray *)convertJSONToItemArray:(NSData *)data {
103
+-(NSArray *)convertJSONToItemArray:(NSData *)data ShowSubs:(Boolean)showSubs {
103
     NSError *error;
104
     NSError *error;
104
     NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
105
     NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
105
     NSDictionary *dat = [json valueForKey:@"data"];
106
     NSDictionary *dat = [json valueForKey:@"data"];
121
         if (!isSelf) {
122
         if (!isSelf) {
122
             comments = [NSString stringWithFormat:@"http://www.reddit.com%@", [current valueForKey:@"permalink"]];
123
             comments = [NSString stringWithFormat:@"http://www.reddit.com%@", [current valueForKey:@"permalink"]];
123
         }
124
         }
124
-        if ([name length] > maxTitleLength) {
125
-            name = [NSString stringWithFormat:@"%@%@", [name substringToIndex:(maxTitleLength - [replaceTextForTitle length])], replaceTextForTitle];
126
-        }
125
+        NSString *subreddit = [NSString stringWithFormat:subredditFormat, [current valueForKey:@"subreddit"]];
126
+        NSInteger maxLen = maxTitleLength;
127
+        if ([subreddit length] >= maxTitleLength)
128
+            showSubs = FALSE;
129
+        if (showSubs)
130
+            maxLen -= [subreddit length];
131
+        if ([name length] > maxLen)
132
+            name = [NSString stringWithFormat:@"%@%@", [name substringToIndex:(maxLen - [replaceTextForTitle length])], replaceTextForTitle];
133
+        if (showSubs)
134
+            name = [NSString stringWithFormat:@"%@%@", name, subreddit];
127
         RedditItem *r = [RedditItem itemWithName:name Link:link Comments:comments Self:isSelf];
135
         RedditItem *r = [RedditItem itemWithName:name Link:link Comments:comments Self:isSelf];
128
         [r setFullName:[current valueForKey:@"title"]];
136
         [r setFullName:[current valueForKey:@"title"]];
129
         [array insertObject:r atIndex:i];
137
         [array insertObject:r atIndex:i];
140
     NSHTTPURLResponse *response;
148
     NSHTTPURLResponse *response;
141
     
149
     
142
     NSString *after = ((AppDelegate *)parent).lastFullName;
150
     NSString *after = ((AppDelegate *)parent).lastFullName;
151
+    Boolean showSubreddits = ((AppDelegate *)parent).currentState.showSubreddit;
143
     NSString *url;
152
     NSString *url;
144
     if (after == nil)
153
     if (after == nil)
145
         url = [NSString stringWithFormat:@"hot.json?limit=%ld", (long)length];
154
         url = [NSString stringWithFormat:@"hot.json?limit=%ld", (long)length];
150
     if ((data == nil) || ([response statusCode] != 200)) {
159
     if ((data == nil) || ([response statusCode] != 200)) {
151
         [parent performSelectorOnMainThread:@selector(reloadListHasFrontpageCallback:) withObject:nil waitUntilDone:false];
160
         [parent performSelectorOnMainThread:@selector(reloadListHasFrontpageCallback:) withObject:nil waitUntilDone:false];
152
     } else {
161
     } else {
153
-        [parent performSelectorOnMainThread:@selector(reloadListHasFrontpageCallback:) withObject:[self convertJSONToItemArray:data] waitUntilDone:false];
162
+        [parent performSelectorOnMainThread:@selector(reloadListHasFrontpageCallback:) withObject:[self convertJSONToItemArray:data ShowSubs:showSubreddits] waitUntilDone:false];
154
     }
163
     }
155
 }
164
 }
156
 
165
 
164
     }
173
     }
165
     
174
     
166
     NSString *after = ((AppDelegate *)parent).lastFullName;
175
     NSString *after = ((AppDelegate *)parent).lastFullName;
176
+    Boolean showSubreddits = ((AppDelegate *)parent).currentState.showSubreddit;
167
     NSString *url;
177
     NSString *url;
168
     if (after == nil)
178
     if (after == nil)
169
         url = [NSString stringWithFormat:@"%@/hot.json?limit=%ld", subs, (long)length];
179
         url = [NSString stringWithFormat:@"%@/hot.json?limit=%ld", subs, (long)length];
175
     if ((data == nil) || ([response statusCode] != 200)) {
185
     if ((data == nil) || ([response statusCode] != 200)) {
176
         [parent performSelectorOnMainThread:@selector(reloadListHasSubredditsCallback:) withObject:nil waitUntilDone:false];
186
         [parent performSelectorOnMainThread:@selector(reloadListHasSubredditsCallback:) withObject:nil waitUntilDone:false];
177
     } else {
187
     } else {
178
-        [parent performSelectorOnMainThread:@selector(reloadListHasSubredditsCallback:) withObject:[self convertJSONToItemArray:data] waitUntilDone:false];
188
+        [parent performSelectorOnMainThread:@selector(reloadListHasSubredditsCallback:) withObject:[self convertJSONToItemArray:data ShowSubs:showSubreddits] waitUntilDone:false];
179
     }
189
     }
180
 }
190
 }
181
 
191
 

+ 1
- 1
RedditBar/RedditBar-Info.plist View File

21
 	<key>CFBundleSignature</key>
21
 	<key>CFBundleSignature</key>
22
 	<string>????</string>
22
 	<string>????</string>
23
 	<key>CFBundleVersion</key>
23
 	<key>CFBundleVersion</key>
24
-	<string>175</string>
24
+	<string>185</string>
25
 	<key>LSApplicationCategoryType</key>
25
 	<key>LSApplicationCategoryType</key>
26
 	<string>public.app-category.utilities</string>
26
 	<string>public.app-category.utilities</string>
27
 	<key>LSMinimumSystemVersion</key>
27
 	<key>LSMinimumSystemVersion</key>

+ 1
- 0
RedditBar/StateModel.h View File

35
 @property (atomic) Boolean useSubscriptions;
35
 @property (atomic) Boolean useSubscriptions;
36
 @property (atomic, retain) NSArray *subreddits;
36
 @property (atomic, retain) NSArray *subreddits;
37
 @property (atomic) NSInteger length;
37
 @property (atomic) NSInteger length;
38
+@property (atomic) Boolean showSubreddit;
38
 
39
 
39
 @end
40
 @end

+ 1
- 1
RedditBar/StateModel.m View File

30
 
30
 
31
 @implementation StateModel
31
 @implementation StateModel
32
 
32
 
33
-@synthesize username, modhash, useSubscriptions, subreddits;
33
+@synthesize username, modhash, useSubscriptions, subreddits, showSubreddit;
34
 
34
 
35
 @end
35
 @end

+ 6
- 0
RedditBar/de.lproj/Localizable.strings View File

40
 /* Pref Error */
40
 /* Pref Error */
41
 "Subreddit List Invalid!" = "Ungültige Subreddit-liste";
41
 "Subreddit List Invalid!" = "Ungültige Subreddit-liste";
42
 
42
 
43
+/* Pref Checkbox State 0 */
44
+"Use Subreddits list" = "Zeige Subreddit Liste";
45
+
46
+/* Pref Checkbox State 1 */
47
+"Use Subscriptions" = "Zeige Abbonements";
48
+
43
 /* Pref API Error */
49
 /* Pref API Error */
44
 "Wrong Username or Password!" = "Falscher Nutzername oder falsches Passwort!";
50
 "Wrong Username or Password!" = "Falscher Nutzername oder falsches Passwort!";
45
 
51
 

+ 3
- 6
RedditBar/de.lproj/Prefs.strings View File

7
 /* Class = "NSMenuItem"; title = "Cut"; ObjectID = "32T-3T-EcY"; */
7
 /* Class = "NSMenuItem"; title = "Cut"; ObjectID = "32T-3T-EcY"; */
8
 "32T-3T-EcY.title" = "Ausschneiden";
8
 "32T-3T-EcY.title" = "Ausschneiden";
9
 
9
 
10
-/* Class = "NSTextFieldCell"; title = "Subreddits:"; ObjectID = "Cmr-7n-CaG"; */
11
-"Cmr-7n-CaG.title" = "Subreddits:";
12
-
13
 /* Class = "NSTextFieldCell"; title = "Items:"; ObjectID = "FNJ-RL-DXT"; */
10
 /* Class = "NSTextFieldCell"; title = "Items:"; ObjectID = "FNJ-RL-DXT"; */
14
 "FNJ-RL-DXT.title" = "Länge:";
11
 "FNJ-RL-DXT.title" = "Länge:";
15
 
12
 
40
 /* Class = "NSTextFieldCell"; title = "Password:"; ObjectID = "m11-YF-fEa"; */
37
 /* Class = "NSTextFieldCell"; title = "Password:"; ObjectID = "m11-YF-fEa"; */
41
 "m11-YF-fEa.title" = "Passwort:";
38
 "m11-YF-fEa.title" = "Passwort:";
42
 
39
 
40
+/* Class = "NSButtonCell"; title = "Show Subreddit after Title"; ObjectID = "nFK-xi-2F3"; */
41
+"nFK-xi-2F3.title" = "Zeige Subreddit hinter Titel";
42
+
43
 /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "qSu-ha-DhM"; */
43
 /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "qSu-ha-DhM"; */
44
 "qSu-ha-DhM.title" = "Alle auswählen";
44
 "qSu-ha-DhM.title" = "Alle auswählen";
45
 
45
 
46
-/* Class = "NSButtonCell"; title = "Subscriptions"; ObjectID = "vW5-Cp-Bm1"; */
47
-"vW5-Cp-Bm1.title" = "Abbonements";
48
-
49
 /* Class = "NSMenuItem"; title = "Copy"; ObjectID = "wSY-To-FDI"; */
46
 /* Class = "NSMenuItem"; title = "Copy"; ObjectID = "wSY-To-FDI"; */
50
 "wSY-To-FDI.title" = "Kopieren";
47
 "wSY-To-FDI.title" = "Kopieren";
51
 
48
 

BIN
RedditBar/en.lproj/Localizable.strings View File


+ 3
- 6
RedditBar/en.lproj/Prefs.strings View File

7
 /* Class = "NSMenuItem"; title = "Cut"; ObjectID = "32T-3T-EcY"; */
7
 /* Class = "NSMenuItem"; title = "Cut"; ObjectID = "32T-3T-EcY"; */
8
 "32T-3T-EcY.title" = "Cut";
8
 "32T-3T-EcY.title" = "Cut";
9
 
9
 
10
-/* Class = "NSTextFieldCell"; title = "Subreddits:"; ObjectID = "Cmr-7n-CaG"; */
11
-"Cmr-7n-CaG.title" = "Subreddits:";
12
-
13
 /* Class = "NSTextFieldCell"; title = "Items:"; ObjectID = "FNJ-RL-DXT"; */
10
 /* Class = "NSTextFieldCell"; title = "Items:"; ObjectID = "FNJ-RL-DXT"; */
14
 "FNJ-RL-DXT.title" = "Items:";
11
 "FNJ-RL-DXT.title" = "Items:";
15
 
12
 
40
 /* Class = "NSTextFieldCell"; title = "Password:"; ObjectID = "m11-YF-fEa"; */
37
 /* Class = "NSTextFieldCell"; title = "Password:"; ObjectID = "m11-YF-fEa"; */
41
 "m11-YF-fEa.title" = "Password:";
38
 "m11-YF-fEa.title" = "Password:";
42
 
39
 
40
+/* Class = "NSButtonCell"; title = "Show Subreddit after Title"; ObjectID = "nFK-xi-2F3"; */
41
+"nFK-xi-2F3.title" = "Show Subreddit after Title";
42
+
43
 /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "qSu-ha-DhM"; */
43
 /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "qSu-ha-DhM"; */
44
 "qSu-ha-DhM.title" = "Select All";
44
 "qSu-ha-DhM.title" = "Select All";
45
 
45
 
46
-/* Class = "NSButtonCell"; title = "Subscriptions"; ObjectID = "vW5-Cp-Bm1"; */
47
-"vW5-Cp-Bm1.title" = "Subscriptions";
48
-
49
 /* Class = "NSMenuItem"; title = "Copy"; ObjectID = "wSY-To-FDI"; */
46
 /* Class = "NSMenuItem"; title = "Copy"; ObjectID = "wSY-To-FDI"; */
50
 "wSY-To-FDI.title" = "Copy";
47
 "wSY-To-FDI.title" = "Copy";
51
 
48
 

+ 3
- 6
RedditBarTests/de.lproj/Prefs.strings View File

7
 /* Class = "NSMenuItem"; title = "Cut"; ObjectID = "32T-3T-EcY"; */
7
 /* Class = "NSMenuItem"; title = "Cut"; ObjectID = "32T-3T-EcY"; */
8
 "32T-3T-EcY.title" = "Cut";
8
 "32T-3T-EcY.title" = "Cut";
9
 
9
 
10
-/* Class = "NSTextFieldCell"; title = "Subreddits:"; ObjectID = "Cmr-7n-CaG"; */
11
-"Cmr-7n-CaG.title" = "Subreddits:";
12
-
13
 /* Class = "NSTextFieldCell"; title = "Items:"; ObjectID = "FNJ-RL-DXT"; */
10
 /* Class = "NSTextFieldCell"; title = "Items:"; ObjectID = "FNJ-RL-DXT"; */
14
 "FNJ-RL-DXT.title" = "Items:";
11
 "FNJ-RL-DXT.title" = "Items:";
15
 
12
 
40
 /* Class = "NSTextFieldCell"; title = "Password:"; ObjectID = "m11-YF-fEa"; */
37
 /* Class = "NSTextFieldCell"; title = "Password:"; ObjectID = "m11-YF-fEa"; */
41
 "m11-YF-fEa.title" = "Password:";
38
 "m11-YF-fEa.title" = "Password:";
42
 
39
 
40
+/* Class = "NSButtonCell"; title = "Show Subreddit after Title"; ObjectID = "nFK-xi-2F3"; */
41
+"nFK-xi-2F3.title" = "Show Subreddit after Title";
42
+
43
 /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "qSu-ha-DhM"; */
43
 /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "qSu-ha-DhM"; */
44
 "qSu-ha-DhM.title" = "Select All";
44
 "qSu-ha-DhM.title" = "Select All";
45
 
45
 
46
-/* Class = "NSButtonCell"; title = "Subscriptions"; ObjectID = "vW5-Cp-Bm1"; */
47
-"vW5-Cp-Bm1.title" = "Subscriptions";
48
-
49
 /* Class = "NSMenuItem"; title = "Copy"; ObjectID = "wSY-To-FDI"; */
46
 /* Class = "NSMenuItem"; title = "Copy"; ObjectID = "wSY-To-FDI"; */
50
 "wSY-To-FDI.title" = "Copy";
47
 "wSY-To-FDI.title" = "Copy";
51
 
48
 

+ 3
- 6
RedditBarTests/en.lproj/Prefs.strings View File

7
 /* Class = "NSMenuItem"; title = "Cut"; ObjectID = "32T-3T-EcY"; */
7
 /* Class = "NSMenuItem"; title = "Cut"; ObjectID = "32T-3T-EcY"; */
8
 "32T-3T-EcY.title" = "Cut";
8
 "32T-3T-EcY.title" = "Cut";
9
 
9
 
10
-/* Class = "NSTextFieldCell"; title = "Subreddits:"; ObjectID = "Cmr-7n-CaG"; */
11
-"Cmr-7n-CaG.title" = "Subreddits:";
12
-
13
 /* Class = "NSTextFieldCell"; title = "Items:"; ObjectID = "FNJ-RL-DXT"; */
10
 /* Class = "NSTextFieldCell"; title = "Items:"; ObjectID = "FNJ-RL-DXT"; */
14
 "FNJ-RL-DXT.title" = "Items:";
11
 "FNJ-RL-DXT.title" = "Items:";
15
 
12
 
40
 /* Class = "NSTextFieldCell"; title = "Password:"; ObjectID = "m11-YF-fEa"; */
37
 /* Class = "NSTextFieldCell"; title = "Password:"; ObjectID = "m11-YF-fEa"; */
41
 "m11-YF-fEa.title" = "Password:";
38
 "m11-YF-fEa.title" = "Password:";
42
 
39
 
40
+/* Class = "NSButtonCell"; title = "Show Subreddit after Title"; ObjectID = "nFK-xi-2F3"; */
41
+"nFK-xi-2F3.title" = "Show Subreddit after Title";
42
+
43
 /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "qSu-ha-DhM"; */
43
 /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "qSu-ha-DhM"; */
44
 "qSu-ha-DhM.title" = "Select All";
44
 "qSu-ha-DhM.title" = "Select All";
45
 
45
 
46
-/* Class = "NSButtonCell"; title = "Subscriptions"; ObjectID = "vW5-Cp-Bm1"; */
47
-"vW5-Cp-Bm1.title" = "Subscriptions";
48
-
49
 /* Class = "NSMenuItem"; title = "Copy"; ObjectID = "wSY-To-FDI"; */
46
 /* Class = "NSMenuItem"; title = "Copy"; ObjectID = "wSY-To-FDI"; */
50
 "wSY-To-FDI.title" = "Copy";
47
 "wSY-To-FDI.title" = "Copy";
51
 
48
 

Loading…
Cancel
Save