Browse Source

Started PM feature.

Added Preference for refresh interval. Added new Icons. Implemented NSTimer and icon switching.
Only fetching the PMs and putting them in the menu is still unimplemented.
Thomas Buck 10 years ago
parent
commit
6d38d70ce1

+ 5
- 1
RedditBar/AppDelegate.h View File

@@ -40,12 +40,15 @@
40 40
 @property (atomic, retain) NSStatusItem *statusItem;
41 41
 @property (atomic, retain) NSImage *statusImage;
42 42
 @property (atomic, retain) NSImage *statusHighlightImage;
43
+@property (atomic, retain) NSImage *orangeredImage;
44
+@property (atomic, retain) NSImage *orangeredHighlightImage;
43 45
 @property (atomic, retain) PrefController *prefWindow;
44 46
 @property (atomic, retain) StateModel *currentState;
45 47
 @property (atomic, retain) Reddit *api;
46 48
 @property (atomic, retain) NSArray *menuItems;
47 49
 @property (atomic, retain) NSArray *redditItems;
48 50
 @property (atomic, retain) NSString *lastFullName;
51
+@property (atomic, retain) NSTimer *refreshTimer;
49 52
 
50 53
 -(IBAction)showPreferences:(id)sender;
51 54
 -(IBAction)showAbout:(id)sender;
@@ -58,7 +61,8 @@
58 61
 -(void)reloadListNotAuthenticatedCallback;
59 62
 -(void)reloadListHasSubredditsCallback:(NSArray *)items;
60 63
 -(void)reloadListHasFrontpageCallback:(NSArray *)items;
64
+-(void)readPMsCallback:(NSArray *)items;
61 65
 
62
--(void)prefReturnName:(NSString *)name Modhash:(NSString *)modhash subscriptions:(Boolean)subscriptions subreddits:(NSString *)subreddits length:(NSInteger)length printSubs:(Boolean)showSubreddits titleLength:(NSInteger)titleLength;
66
+-(void)prefReturnName:(NSString *)name Modhash:(NSString *)modhash subscriptions:(Boolean)subscriptions subreddits:(NSString *)subreddits length:(NSInteger)length printSubs:(Boolean)showSubreddits titleLength:(NSInteger)titleLength refresh:(NSInteger)refreshInterval;
63 67
 
64 68
 @end

+ 29
- 2
RedditBar/AppDelegate.m View File

@@ -30,13 +30,15 @@
30 30
 
31 31
 @implementation AppDelegate
32 32
 
33
-@synthesize statusMenu, statusItem, statusImage, statusHighlightImage, prefWindow, currentState, application, api, firstMenuItem, menuItems, redditItems, lastFullName;
33
+@synthesize statusMenu, statusItem, statusImage, statusHighlightImage, orangeredImage, orangeredHighlightImage, prefWindow, currentState, application, api, firstMenuItem, menuItems, redditItems, lastFullName, refreshTimer;
34 34
 
35 35
 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
36 36
     statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength];
37 37
     NSBundle *bundle = [NSBundle mainBundle];
38 38
     statusImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForResource:@"icon" ofType:@"png"]];
39 39
     statusHighlightImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForResource:@"icon-alt" ofType:@"png"]];
40
+    orangeredImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForResource:@"orangered" ofType:@"png"]];
41
+    orangeredHighlightImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForResource:@"orangered-alt" ofType:@"png"]];
40 42
     [statusItem setImage:statusImage];
41 43
     [statusItem setAlternateImage:statusHighlightImage];
42 44
     [statusItem setMenu:statusMenu];
@@ -47,6 +49,29 @@
47 49
     [currentState loadPreferences];
48 50
     lastFullName = nil;
49 51
     [self reloadListWithOptions];
52
+    [self recreateRefreshTimer];
53
+}
54
+
55
+-(void)recreateRefreshTimer {
56
+    if (refreshTimer != nil)
57
+        [refreshTimer invalidate];
58
+    refreshTimer = [NSTimer scheduledTimerWithTimeInterval:(currentState.refreshInterval * 60) target:self selector:@selector(refreshTick:) userInfo:nil repeats:YES];
59
+    [refreshTimer fire];
60
+}
61
+
62
+-(void)refreshTick:(NSTimer *)timer {
63
+    [NSThread detachNewThreadSelector:@selector(readPMs:) toTarget:api withObject:self];
64
+}
65
+
66
+-(void)readPMsCallback:(NSArray *)items {
67
+    if (items == nil) {
68
+        [statusItem setImage:statusImage];
69
+        [statusItem setAlternateImage:statusHighlightImage];
70
+    } else {
71
+        [statusItem setImage:orangeredImage];
72
+        [statusItem setAlternateImage:orangeredHighlightImage];
73
+        // TODO put PMs in menu?!
74
+    }
50 75
 }
51 76
 
52 77
 -(void)reloadListNotAuthenticatedCallback {
@@ -200,7 +225,7 @@
200 225
     [application orderFrontStandardAboutPanel:self];
201 226
 }
202 227
 
203
--(void)prefReturnName:(NSString *)name Modhash:(NSString *)modhash subscriptions:(Boolean)subscriptions subreddits:(NSString *)subreddits length:(NSInteger)length printSubs:(Boolean)showSubreddits titleLength:(NSInteger)titleLength {
228
+-(void)prefReturnName:(NSString *)name Modhash:(NSString *)modhash subscriptions:(Boolean)subscriptions subreddits:(NSString *)subreddits length:(NSInteger)length printSubs:(Boolean)showSubreddits titleLength:(NSInteger)titleLength refresh:(NSInteger)refreshInterval {
204 229
     currentState.username = name;
205 230
     currentState.modhash = modhash;
206 231
     currentState.useSubscriptions = subscriptions;
@@ -208,9 +233,11 @@
208 233
     currentState.length = length;
209 234
     currentState.showSubreddit = showSubreddits;
210 235
     currentState.titleLength = titleLength;
236
+    currentState.refreshInterval = refreshInterval;
211 237
     [currentState savePreferences];
212 238
     lastFullName = nil; // reload from start
213 239
     [self reloadListWithOptions];
240
+    [self recreateRefreshTimer];
214 241
 }
215 242
 
216 243
 @end

+ 9
- 0
RedditBar/Base.lproj/Prefs.strings View File

@@ -35,9 +35,15 @@
35 35
 /* Class = "NSTextFieldCell"; title = "66"; ObjectID = "b76-4r-MEp"; */
36 36
 "b76-4r-MEp.title" = "66";
37 37
 
38
+/* Class = "NSTextFieldCell"; title = "PM Refresh (in Minutes):"; ObjectID = "cwK-wP-wB6"; */
39
+"cwK-wP-wB6.title" = "PM Refresh (in Minutes):";
40
+
38 41
 /* Class = "NSMenuItem"; title = "Edit"; ObjectID = "czz-51-wxr"; */
39 42
 "czz-51-wxr.title" = "Edit";
40 43
 
44
+/* Class = "NSTextFieldCell"; title = "5"; ObjectID = "gZN-n2-TGX"; */
45
+"gZN-n2-TGX.title" = "5";
46
+
41 47
 /* Class = "NSMenuItem"; title = "Paste"; ObjectID = "j3h-hj-rfI"; */
42 48
 "j3h-hj-rfI.title" = "Paste";
43 49
 
@@ -47,6 +53,9 @@
47 53
 /* Class = "NSButtonCell"; title = "Show Subreddit after Title"; ObjectID = "nFK-xi-2F3"; */
48 54
 "nFK-xi-2F3.title" = "Show Subreddit after Title";
49 55
 
56
+/* Class = "NSBox"; title = "Box"; ObjectID = "paW-kV-tNF"; */
57
+"paW-kV-tNF.title" = "Box";
58
+
50 59
 /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "qSu-ha-DhM"; */
51 60
 "qSu-ha-DhM.title" = "Select All";
52 61
 

+ 68
- 17
RedditBar/Base.lproj/Prefs.xib View File

@@ -1,5 +1,5 @@
1 1
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4514" systemVersion="13A603" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
2
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
3 3
     <dependencies>
4 4
         <deployment defaultVersion="1080" identifier="macosx"/>
5 5
         <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4514"/>
@@ -11,6 +11,8 @@
11 11
                 <outlet property="lengthStepper" destination="jxz-fQ-M1L" id="NK5-G4-9UJ"/>
12 12
                 <outlet property="password" destination="ARP-lb-J16" id="EDd-om-ciF"/>
13 13
                 <outlet property="progress" destination="vz0-tR-n1f" id="t06-dO-WKY"/>
14
+                <outlet property="refreshField" destination="2J7-SH-Grc" id="tsA-1R-BUz"/>
15
+                <outlet property="refreshStepper" destination="uaS-Xm-tIa" id="1bf-OR-gsX"/>
14 16
                 <outlet property="showSubreddit" destination="fRR-M9-szp" id="bGR-ej-R9R"/>
15 17
                 <outlet property="subreddits" destination="EhP-FS-8dT" id="td1-kv-jQm"/>
16 18
                 <outlet property="subscriptions" destination="vW5-Cp-Bm1" id="gja-K0-7Uh"/>
@@ -25,14 +27,14 @@
25 27
         <window title="RedditBar Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" oneShot="NO" releasedWhenClosed="NO" wantsToBeColor="NO" animationBehavior="default" id="1" customClass="PrefWindow">
26 28
             <windowStyleMask key="styleMask" titled="YES" closable="YES"/>
27 29
             <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
28
-            <rect key="contentRect" x="196" y="240" width="340" height="323"/>
30
+            <rect key="contentRect" x="196" y="240" width="340" height="363"/>
29 31
             <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1058"/>
30 32
             <view key="contentView" id="2">
31
-                <rect key="frame" x="0.0" y="0.0" width="340" height="323"/>
33
+                <rect key="frame" x="0.0" y="0.0" width="340" height="363"/>
32 34
                 <autoresizingMask key="autoresizingMask"/>
33 35
                 <subviews>
34 36
                     <textField verticalHuggingPriority="750" id="0mi-88-o94">
35
-                        <rect key="frame" x="120" y="283" width="200" height="22"/>
37
+                        <rect key="frame" x="120" y="323" width="200" height="22"/>
36 38
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
37 39
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="xlI-hU-MqM">
38 40
                             <font key="font" metaFont="system"/>
@@ -41,7 +43,7 @@
41 43
                         </textFieldCell>
42 44
                     </textField>
43 45
                     <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="f72-fM-yQc">
44
-                        <rect key="frame" x="18" y="288" width="96" height="17"/>
46
+                        <rect key="frame" x="18" y="328" width="96" height="17"/>
45 47
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
46 48
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Username: " id="GTO-OP-MYS">
47 49
                             <font key="font" metaFont="system"/>
@@ -50,7 +52,7 @@
50 52
                         </textFieldCell>
51 53
                     </textField>
52 54
                     <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="JMQ-a6-DKC">
53
-                        <rect key="frame" x="18" y="254" width="96" height="17"/>
55
+                        <rect key="frame" x="18" y="294" width="96" height="17"/>
54 56
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
55 57
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Password:" id="m11-YF-fEa">
56 58
                             <font key="font" metaFont="system"/>
@@ -59,7 +61,7 @@
59 61
                         </textFieldCell>
60 62
                     </textField>
61 63
                     <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="qFP-pd-32c">
62
-                        <rect key="frame" x="18" y="88" width="63" height="17"/>
64
+                        <rect key="frame" x="18" y="128" width="63" height="17"/>
63 65
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
64 66
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Items:" id="FNJ-RL-DXT">
65 67
                             <font key="font" metaFont="system"/>
@@ -68,7 +70,7 @@
68 70
                         </textFieldCell>
69 71
                     </textField>
70 72
                     <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="O82-1u-lSr">
71
-                        <rect key="frame" x="152" y="88" width="63" height="17"/>
73
+                        <rect key="frame" x="152" y="128" width="63" height="17"/>
72 74
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
73 75
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Title:" id="Frl-AE-ROJ">
74 76
                             <font key="font" metaFont="system"/>
@@ -77,7 +79,7 @@
77 79
                         </textFieldCell>
78 80
                     </textField>
79 81
                     <secureTextField verticalHuggingPriority="750" id="ARP-lb-J16">
80
-                        <rect key="frame" x="120" y="251" width="200" height="22"/>
82
+                        <rect key="frame" x="120" y="291" width="200" height="22"/>
81 83
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
82 84
                         <secureTextFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" usesSingleLineMode="YES" id="We7-pG-rAt">
83 85
                             <font key="font" metaFont="system"/>
@@ -114,7 +116,7 @@ Gw
114 116
                         </connections>
115 117
                     </button>
116 118
                     <scrollView horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" id="8ew-wY-1Yh">
117
-                        <rect key="frame" x="20" y="113" width="300" height="100"/>
119
+                        <rect key="frame" x="20" y="153" width="300" height="100"/>
118 120
                         <autoresizingMask key="autoresizingMask"/>
119 121
                         <clipView key="contentView" copiesOnScroll="NO" id="ENU-Jw-8fO">
120 122
                             <rect key="frame" x="1" y="1" width="298" height="98"/>
@@ -143,7 +145,7 @@ Gw
143 145
                         </scroller>
144 146
                     </scrollView>
145 147
                     <button id="XZM-90-hQ8">
146
-                        <rect key="frame" x="18" y="220" width="280" height="25"/>
148
+                        <rect key="frame" x="18" y="260" width="280" height="25"/>
147 149
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
148 150
                         <buttonCell key="cell" type="check" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="vW5-Cp-Bm1">
149 151
                             <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -154,7 +156,7 @@ Gw
154 156
                         </connections>
155 157
                     </button>
156 158
                     <textField verticalHuggingPriority="750" id="MAv-jO-hIv">
157
-                        <rect key="frame" x="87" y="85" width="38" height="22"/>
159
+                        <rect key="frame" x="87" y="125" width="38" height="22"/>
158 160
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
159 161
                         <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">
160 162
                             <font key="font" metaFont="system"/>
@@ -167,7 +169,7 @@ Gw
167 169
                         </connections>
168 170
                     </textField>
169 171
                     <textField verticalHuggingPriority="750" id="qju-1J-OOV">
170
-                        <rect key="frame" x="221" y="85" width="38" height="22"/>
172
+                        <rect key="frame" x="221" y="125" width="38" height="22"/>
171 173
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
172 174
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="right" title="66" drawsBackground="YES" id="b76-4r-MEp">
173 175
                             <font key="font" metaFont="system"/>
@@ -180,7 +182,7 @@ Gw
180 182
                         </connections>
181 183
                     </textField>
182 184
                     <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" id="jxz-fQ-M1L">
183
-                        <rect key="frame" x="130" y="82" width="19" height="27"/>
185
+                        <rect key="frame" x="130" y="122" width="19" height="27"/>
184 186
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
185 187
                         <stepperCell key="cell" continuous="YES" alignment="left" maxValue="100" id="Gba-jV-Ouh"/>
186 188
                         <connections>
@@ -189,7 +191,7 @@ Gw
189 191
                         </connections>
190 192
                     </stepper>
191 193
                     <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" id="2aV-fo-xh7">
192
-                        <rect key="frame" x="264" y="82" width="19" height="27"/>
194
+                        <rect key="frame" x="264" y="122" width="19" height="27"/>
193 195
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
194 196
                         <stepperCell key="cell" continuous="YES" alignment="left" maxValue="100" id="BWQ-gm-H9h"/>
195 197
                         <connections>
@@ -198,17 +200,55 @@ Gw
198 200
                         </connections>
199 201
                     </stepper>
200 202
                     <progressIndicator canDrawConcurrently="YES" horizontalHuggingPriority="750" verticalHuggingPriority="750" maxValue="100" displayedWhenStopped="NO" bezeled="NO" indeterminate="YES" controlSize="small" style="spinning" id="vz0-tR-n1f">
201
-                        <rect key="frame" x="304" y="224" width="16" height="16"/>
203
+                        <rect key="frame" x="304" y="264" width="16" height="16"/>
202 204
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
203 205
                     </progressIndicator>
204 206
                     <button id="fRR-M9-szp">
205
-                        <rect key="frame" x="18" y="53" width="304" height="18"/>
207
+                        <rect key="frame" x="18" y="93" width="304" height="18"/>
206 208
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
207 209
                         <buttonCell key="cell" type="check" title="Show Subreddit after Title" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="nFK-xi-2F3">
208 210
                             <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
209 211
                             <font key="font" metaFont="system"/>
210 212
                         </buttonCell>
211 213
                     </button>
214
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="6zt-jq-NXJ">
215
+                        <rect key="frame" x="18" y="61" width="236" height="17"/>
216
+                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
217
+                        <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="PM Refresh (in Minutes):" id="cwK-wP-wB6">
218
+                            <font key="font" metaFont="system"/>
219
+                            <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
220
+                            <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
221
+                        </textFieldCell>
222
+                    </textField>
223
+                    <box autoresizesSubviews="NO" verticalHuggingPriority="750" title="Box" boxType="separator" titlePosition="noTitle" id="paW-kV-tNF">
224
+                        <rect key="frame" x="12" y="84" width="316" height="5"/>
225
+                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
226
+                        <color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
227
+                        <color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
228
+                        <font key="titleFont" metaFont="system"/>
229
+                    </box>
230
+                    <textField verticalHuggingPriority="750" id="2J7-SH-Grc">
231
+                        <rect key="frame" x="260" y="58" width="38" height="22"/>
232
+                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
233
+                        <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="right" title="5" drawsBackground="YES" id="gZN-n2-TGX">
234
+                            <font key="font" metaFont="system"/>
235
+                            <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
236
+                            <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
237
+                        </textFieldCell>
238
+                        <connections>
239
+                            <action selector="refreshDidChange:" target="-2" id="Gzn-Nf-hhb"/>
240
+                            <outlet property="formatter" destination="Y11-Cs-X1g" id="m31-5r-Nka"/>
241
+                        </connections>
242
+                    </textField>
243
+                    <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" id="uaS-Xm-tIa">
244
+                        <rect key="frame" x="303" y="55" width="19" height="27"/>
245
+                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
246
+                        <stepperCell key="cell" continuous="YES" alignment="left" maxValue="100" id="rTZ-Zs-1eO"/>
247
+                        <connections>
248
+                            <action selector="refreshDidChange:" target="-2" id="4Di-oE-RDC"/>
249
+                            <outlet property="formatter" destination="Y11-Cs-X1g" id="hoL-jC-QPe"/>
250
+                        </connections>
251
+                    </stepper>
212 252
                 </subviews>
213 253
             </view>
214 254
         </window>
@@ -234,6 +274,17 @@ Gw
234 274
                 <real key="inspectorSampleValue" value="1"/>
235 275
             </metadata>
236 276
         </numberFormatter>
277
+        <numberFormatter formatterBehavior="10_0" positiveFormat="0" negativeFormat="-0" hasThousandSeparators="NO" thousandSeparator="." id="Y11-Cs-X1g">
278
+            <attributedString key="attributedStringForZero">
279
+                <fragment content="0"/>
280
+            </attributedString>
281
+            <real key="minimum" value="0.0"/>
282
+            <decimal key="maximum" value="NaN"/>
283
+            <metadata>
284
+                <bool key="localizesFormat" value="YES"/>
285
+                <real key="inspectorSampleValue" value="1"/>
286
+            </metadata>
287
+        </numberFormatter>
237 288
         <menu title="Main Menu" systemMenu="main" id="IWp-hb-gSM">
238 289
             <items>
239 290
                 <menuItem title="Edit" id="czz-51-wxr">

+ 4
- 0
RedditBar/PrefController.h View File

@@ -46,10 +46,14 @@
46 46
 @property (atomic, retain) IBOutlet NSTextField *titleField;
47 47
 @property (atomic, retain) IBOutlet NSStepper *titleStepper;
48 48
 @property (atomic) NSInteger titleLength;
49
+@property (atomic, retain) IBOutlet NSTextField *refreshField;
50
+@property (atomic, retain) IBOutlet NSStepper *refreshStepper;
51
+@property (atomic) NSInteger refreshInterval;
49 52
 
50 53
 -(IBAction)buttonSave:(id)sender;
51 54
 -(IBAction)toggleSubs:(id)sender;
52 55
 -(IBAction)lengthDidChange:(id)sender;
53 56
 -(IBAction)titleDidChange:(id)sender;
57
+-(IBAction)refreshDidChange:(id)sender;
54 58
 
55 59
 @end

+ 11
- 2
RedditBar/PrefController.m View File

@@ -34,7 +34,7 @@
34 34
 NSString *modhashSetLiteral = @"__MODHASH__IS__SET__";
35 35
 NSString *subredditCharacters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_\n";
36 36
 
37
-@synthesize username, password, subscriptions, subreddits, win, parent, state, lengthField, lengthStepper, length, progress, showSubreddit, titleField, titleStepper, titleLength;
37
+@synthesize username, password, subscriptions, subreddits, win, parent, state, lengthField, lengthStepper, length, progress, showSubreddit, titleField, titleStepper, titleLength, refreshField, refreshStepper, refreshInterval;
38 38
 
39 39
 -(Boolean)isValidList:(NSString *)input {
40 40
     NSCharacterSet *invalidChars = [[NSCharacterSet characterSetWithCharactersInString:subredditCharacters] invertedSet];
@@ -65,6 +65,9 @@ NSString *subredditCharacters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRST
65 65
     titleLength = state.titleLength;
66 66
     [titleStepper setIntegerValue:titleLength];
67 67
     [titleField setIntegerValue:titleLength];
68
+    refreshInterval = state.refreshInterval;
69
+    [refreshStepper setIntegerValue:refreshInterval];
70
+    [refreshField setIntegerValue:refreshInterval];
68 71
     [progress setUsesThreadedAnimation:YES];
69 72
     [showSubreddit setState:[NSNumber numberWithBool:state.showSubreddit].integerValue];
70 73
 }
@@ -129,7 +132,7 @@ NSString *subredditCharacters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRST
129 132
         print = FALSE;
130 133
     
131 134
     AppDelegate *app = (AppDelegate *)parent;
132
-    [app prefReturnName:username.stringValue Modhash:modhash subscriptions:subs subreddits:subreddits.textStorage.string length:[lengthField integerValue] printSubs:print titleLength:[titleField integerValue]];
135
+    [app prefReturnName:username.stringValue Modhash:modhash subscriptions:subs subreddits:subreddits.textStorage.string length:[lengthField integerValue] printSubs:print titleLength:[titleField integerValue] refresh:[refreshField integerValue]];
133 136
     [win performClose:self];
134 137
 }
135 138
 
@@ -155,4 +158,10 @@ NSString *subredditCharacters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRST
155 158
     [titleField setIntegerValue:titleLength];
156 159
 }
157 160
 
161
+-(IBAction)refreshDidChange:(id)sender {
162
+    refreshInterval = [sender integerValue];
163
+    [refreshStepper setIntegerValue:refreshInterval];
164
+    [refreshField setIntegerValue:refreshInterval];
165
+}
166
+
158 167
 @end

+ 1
- 0
RedditBar/Reddit.h View File

@@ -52,6 +52,7 @@
52 52
 -(void)isAuthenticatedNewModhash:(id)parent;
53 53
 -(void)readFrontpage:(id)parent;
54 54
 -(void)readSubreddits:(id)parent;
55
+-(void)readPMs:(id)parent;
55 56
 
56 57
 // Internal
57 58
 -(NSData *)queryAPI:(NSString *)api withData:(NSString *)string andResponse:(NSHTTPURLResponse **)res;

+ 8
- 2
RedditBar/Reddit.m View File

@@ -187,12 +187,18 @@ NSString *subredditFormat = @" [r/%@]";
187 187
     NSHTTPURLResponse *response;
188 188
     NSData *data = [self queryAPI:url withResponse:&response];
189 189
     if ((data == nil) || ([response statusCode] != 200)) {
190
-        [parent performSelectorOnMainThread:@selector(reloadListHasSubredditsCallback:) withObject:nil waitUntilDone:false];
190
+        [(AppDelegate *)parent performSelectorOnMainThread:@selector(reloadListHasSubredditsCallback:) withObject:nil waitUntilDone:FALSE];
191 191
     } else {
192
-        [parent performSelectorOnMainThread:@selector(reloadListHasSubredditsCallback:) withObject:[self convertJSONToItemArray:data ShowSubs:showSubreddits] waitUntilDone:false];
192
+        [(AppDelegate *)parent performSelectorOnMainThread:@selector(reloadListHasSubredditsCallback:) withObject:[self convertJSONToItemArray:data ShowSubs:showSubreddits] waitUntilDone:FALSE];
193 193
     }
194 194
 }
195 195
 
196
+-(void)readPMs:(id)parent {
197
+    // TODO read PMs
198
+    // Fill NSArray with RedditItems for each PM, or return nil if none
199
+    [(AppDelegate *)parent performSelectorOnMainThread:@selector(readPMsCallback:) withObject:nil waitUntilDone:FALSE];
200
+}
201
+
196 202
 -(void)isAuthenticatedNewModhash:(id)parent {
197 203
     NSHTTPURLResponse *response;
198 204
     NSData *dat = [self queryAPI:@"api/me.json" withResponse:&response];

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

@@ -21,7 +21,7 @@
21 21
 	<key>CFBundleSignature</key>
22 22
 	<string>????</string>
23 23
 	<key>CFBundleVersion</key>
24
-	<string>234</string>
24
+	<string>249</string>
25 25
 	<key>LSApplicationCategoryType</key>
26 26
 	<string>public.app-category.utilities</string>
27 27
 	<key>LSMinimumSystemVersion</key>

+ 5
- 5
RedditBar/RedditItem.h View File

@@ -30,11 +30,11 @@
30 30
 
31 31
 @interface RedditItem : NSObject
32 32
 
33
-@property (atomic, retain) NSString *name;
34
-@property (atomic, retain) NSString *fullName;
35
-@property (atomic, retain) NSString *link;
36
-@property (atomic, retain) NSString *comments;
37
-@property (atomic) BOOL isSelf;
33
+@property (atomic, retain) NSString *name; // Title, maybe cut with ... at the end
34
+@property (atomic, retain) NSString *fullName; // Complete Title
35
+@property (atomic, retain) NSString *link; // link itself
36
+@property (atomic, retain) NSString *comments; // link to comments, or nil if isSelf is true
37
+@property (atomic) BOOL isSelf; // link or selfpost
38 38
 
39 39
 +(RedditItem *)itemWithName:(NSString *)name Link:(NSString *)link Comments:(NSString *)comments Self:(BOOL)isSelf;
40 40
 

+ 1
- 0
RedditBar/StateModel.h View File

@@ -37,6 +37,7 @@
37 37
 @property (atomic) NSInteger length;
38 38
 @property (atomic) Boolean showSubreddit;
39 39
 @property (atomic) NSInteger titleLength;
40
+@property (atomic) NSInteger refreshInterval;
40 41
 
41 42
 -(void)registerDefaultPreferences;
42 43
 -(void)savePreferences;

+ 5
- 1
RedditBar/StateModel.m View File

@@ -30,7 +30,7 @@
30 30
 
31 31
 @implementation StateModel
32 32
 
33
-@synthesize username, modhash, useSubscriptions, subreddits, length, showSubreddit, titleLength;
33
+@synthesize username, modhash, useSubscriptions, subreddits, length, showSubreddit, titleLength, refreshInterval;
34 34
 
35 35
 NSString *s_username = @"username";
36 36
 NSString *s_modhash = @"modhash";
@@ -39,6 +39,7 @@ NSString *s_subreddits = @"subreddits";
39 39
 NSString *s_length = @"length";
40 40
 NSString *s_subs = @"showSubs";
41 41
 NSString *s_title = @"titleLength";
42
+NSString *s_refresh = @"refreshInterval";
42 43
 
43 44
 -(void)registerDefaultPreferences {
44 45
     NSUserDefaults *store = [NSUserDefaults standardUserDefaults];
@@ -48,6 +49,7 @@ NSString *s_title = @"titleLength";
48 49
     [appDefaults setValue:[NSNumber numberWithInt:10] forKey:s_length];
49 50
     [appDefaults setValue:[NSNumber numberWithBool:YES] forKey:s_subs];
50 51
     [appDefaults setValue:[NSNumber numberWithInt:66] forKey:s_title];
52
+    [appDefaults setValue:[NSNumber numberWithInt:5] forKey:s_refresh];
51 53
     [store registerDefaults:appDefaults];
52 54
 }
53 55
 
@@ -60,6 +62,7 @@ NSString *s_title = @"titleLength";
60 62
     [store setInteger:length forKey:s_length];
61 63
     [store setBool:showSubreddit forKey:s_subs];
62 64
     [store setInteger:titleLength forKey:s_title];
65
+    [store setInteger:refreshInterval forKey:s_refresh];
63 66
     [store synchronize];
64 67
 }
65 68
 
@@ -73,6 +76,7 @@ NSString *s_title = @"titleLength";
73 76
     length = [store integerForKey:s_length];
74 77
     showSubreddit = [store boolForKey:s_subs];
75 78
     titleLength = [store integerForKey:s_title];
79
+    refreshInterval = [store integerForKey:s_refresh];
76 80
 }
77 81
 
78 82
 @end

+ 9
- 0
RedditBar/de.lproj/Prefs.strings View File

@@ -34,9 +34,15 @@
34 34
 /* Class = "NSTextFieldCell"; title = "66"; ObjectID = "b76-4r-MEp"; */
35 35
 "b76-4r-MEp.title" = "66";
36 36
 
37
+/* Class = "NSTextFieldCell"; title = "PM Refresh (in Minutes):"; ObjectID = "cwK-wP-wB6"; */
38
+"cwK-wP-wB6.title" = "PM Aktualisierung (in Minuten):";
39
+
37 40
 /* Class = "NSMenuItem"; title = "Edit"; ObjectID = "czz-51-wxr"; */
38 41
 "czz-51-wxr.title" = "Bearbeiten";
39 42
 
43
+/* Class = "NSTextFieldCell"; title = "5"; ObjectID = "gZN-n2-TGX"; */
44
+"gZN-n2-TGX.title" = "5";
45
+
40 46
 /* Class = "NSMenuItem"; title = "Paste"; ObjectID = "j3h-hj-rfI"; */
41 47
 "j3h-hj-rfI.title" = "Einfügen";
42 48
 
@@ -46,6 +52,9 @@
46 52
 /* Class = "NSButtonCell"; title = "Show Subreddit after Title"; ObjectID = "nFK-xi-2F3"; */
47 53
 "nFK-xi-2F3.title" = "Zeige Subreddit hinter Titel";
48 54
 
55
+/* Class = "NSBox"; title = "Box"; ObjectID = "paW-kV-tNF"; */
56
+"paW-kV-tNF.title" = "Box";
57
+
49 58
 /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "qSu-ha-DhM"; */
50 59
 "qSu-ha-DhM.title" = "Alle auswählen";
51 60
 

+ 9
- 0
RedditBar/en.lproj/Prefs.strings View File

@@ -34,9 +34,15 @@
34 34
 /* Class = "NSTextFieldCell"; title = "66"; ObjectID = "b76-4r-MEp"; */
35 35
 "b76-4r-MEp.title" = "66";
36 36
 
37
+/* Class = "NSTextFieldCell"; title = "PM Refresh (in Minutes):"; ObjectID = "cwK-wP-wB6"; */
38
+"cwK-wP-wB6.title" = "PM Refresh (in Minutes):";
39
+
37 40
 /* Class = "NSMenuItem"; title = "Edit"; ObjectID = "czz-51-wxr"; */
38 41
 "czz-51-wxr.title" = "Edit";
39 42
 
43
+/* Class = "NSTextFieldCell"; title = "5"; ObjectID = "gZN-n2-TGX"; */
44
+"gZN-n2-TGX.title" = "5";
45
+
40 46
 /* Class = "NSMenuItem"; title = "Paste"; ObjectID = "j3h-hj-rfI"; */
41 47
 "j3h-hj-rfI.title" = "Paste";
42 48
 
@@ -46,6 +52,9 @@
46 52
 /* Class = "NSButtonCell"; title = "Show Subreddit after Title"; ObjectID = "nFK-xi-2F3"; */
47 53
 "nFK-xi-2F3.title" = "Show Subreddit after Title";
48 54
 
55
+/* Class = "NSBox"; title = "Box"; ObjectID = "paW-kV-tNF"; */
56
+"paW-kV-tNF.title" = "Box";
57
+
49 58
 /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "qSu-ha-DhM"; */
50 59
 "qSu-ha-DhM.title" = "Select All";
51 60
 

+ 9
- 0
RedditBarTests/de.lproj/Prefs.strings View File

@@ -34,9 +34,15 @@
34 34
 /* Class = "NSTextFieldCell"; title = "66"; ObjectID = "b76-4r-MEp"; */
35 35
 "b76-4r-MEp.title" = "66";
36 36
 
37
+/* Class = "NSTextFieldCell"; title = "PM Refresh (in Minutes):"; ObjectID = "cwK-wP-wB6"; */
38
+"cwK-wP-wB6.title" = "PM Refresh (in Minutes):";
39
+
37 40
 /* Class = "NSMenuItem"; title = "Edit"; ObjectID = "czz-51-wxr"; */
38 41
 "czz-51-wxr.title" = "Edit";
39 42
 
43
+/* Class = "NSTextFieldCell"; title = "5"; ObjectID = "gZN-n2-TGX"; */
44
+"gZN-n2-TGX.title" = "5";
45
+
40 46
 /* Class = "NSMenuItem"; title = "Paste"; ObjectID = "j3h-hj-rfI"; */
41 47
 "j3h-hj-rfI.title" = "Paste";
42 48
 
@@ -46,6 +52,9 @@
46 52
 /* Class = "NSButtonCell"; title = "Show Subreddit after Title"; ObjectID = "nFK-xi-2F3"; */
47 53
 "nFK-xi-2F3.title" = "Show Subreddit after Title";
48 54
 
55
+/* Class = "NSBox"; title = "Box"; ObjectID = "paW-kV-tNF"; */
56
+"paW-kV-tNF.title" = "Box";
57
+
49 58
 /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "qSu-ha-DhM"; */
50 59
 "qSu-ha-DhM.title" = "Select All";
51 60
 

+ 9
- 0
RedditBarTests/en.lproj/Prefs.strings View File

@@ -34,9 +34,15 @@
34 34
 /* Class = "NSTextFieldCell"; title = "66"; ObjectID = "b76-4r-MEp"; */
35 35
 "b76-4r-MEp.title" = "66";
36 36
 
37
+/* Class = "NSTextFieldCell"; title = "PM Refresh (in Minutes):"; ObjectID = "cwK-wP-wB6"; */
38
+"cwK-wP-wB6.title" = "PM Refresh (in Minutes):";
39
+
37 40
 /* Class = "NSMenuItem"; title = "Edit"; ObjectID = "czz-51-wxr"; */
38 41
 "czz-51-wxr.title" = "Edit";
39 42
 
43
+/* Class = "NSTextFieldCell"; title = "5"; ObjectID = "gZN-n2-TGX"; */
44
+"gZN-n2-TGX.title" = "5";
45
+
40 46
 /* Class = "NSMenuItem"; title = "Paste"; ObjectID = "j3h-hj-rfI"; */
41 47
 "j3h-hj-rfI.title" = "Paste";
42 48
 
@@ -46,6 +52,9 @@
46 52
 /* Class = "NSButtonCell"; title = "Show Subreddit after Title"; ObjectID = "nFK-xi-2F3"; */
47 53
 "nFK-xi-2F3.title" = "Show Subreddit after Title";
48 54
 
55
+/* Class = "NSBox"; title = "Box"; ObjectID = "paW-kV-tNF"; */
56
+"paW-kV-tNF.title" = "Box";
57
+
49 58
 /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "qSu-ha-DhM"; */
50 59
 "qSu-ha-DhM.title" = "Select All";
51 60
 

Loading…
Cancel
Save