Skip to content

Commit

Permalink
Add preference for articles limit. Closes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
relikd committed Mar 7, 2019
1 parent fc64025 commit 55aeea5
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 163 deletions.
4 changes: 2 additions & 2 deletions baRSS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.9.1</string>
<string>0.9.2</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand All @@ -32,7 +32,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1078</string>
<string>1122</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSUIElement</key>
Expand Down
2 changes: 1 addition & 1 deletion baRSS/Preferences/General Tab/SettingsGeneral.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
#import <Cocoa/Cocoa.h>

@interface SettingsGeneral : NSViewController

@property (assign) IBOutlet NSView *appearanceView;
@end
352 changes: 197 additions & 155 deletions baRSS/Preferences/General Tab/SettingsGeneral.xib

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions baRSS/Preferences/General Tab/UserPrefs.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,22 @@ + (void)openURLsWithPreferredBrowser:(NSArray<NSURL*>*)urls {

#pragma mark - Hidden Plist Properties -

/// @return The limit on how many links should be opened at the same time, if user holds the option key. Default: @c 10
/// @return The limit on how many links should be opened at the same time, if user holds the option key.
/// Default: @c 10
+ (NSUInteger)openFewLinksLimit {
return (NSUInteger)[self defaultInt:10 forKey:@"openFewLinksLimit"];
}

/// @return The limit on when to truncate article titles (Short names setting must be active). Default: @c 60
/// @return The limit on when to truncate article titles (Short names setting must be active).
/// Default: @c 60
+ (NSUInteger)shortArticleNamesLimit {
return (NSUInteger)[self defaultInt:60 forKey:@"shortArticleNamesLimit"];
}

/// @return The maximum number of articles displayed per feed. Default: @c 0 (no limitation)
/// @return The maximum number of articles displayed per feed (Limit articles setting must be active).
/// Default: @c 40
+ (NSUInteger)articlesInMenuLimit {
return (NSUInteger)[self defaultInt:0 forKey:@"articlesInMenuLimit"];
return (NSUInteger)[self defaultInt:40 forKey:@"articlesInMenuLimit"];
}

@end
7 changes: 7 additions & 0 deletions baRSS/Preferences/Preferences.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ - (IBAction)tabClicked:(NSToolbarItem *)sender {
self.window.contentView = self.settingsGeneral.view;
} else if ([sender.itemIdentifier isEqualToString:@"tabFeeds"]) {
self.window.contentView = self.settingsFeeds.view;
} else if ([sender.itemIdentifier isEqualToString:@"tabAppearance"]) {
if (self.settingsGeneral.view.frame.size.width > 0) {
// using side effect when reading settingsGeneral.view -> will load appearanceView too.
// TODO: generate view programmatically
self.window.contentView = nil;
}
self.window.contentView = self.settingsGeneral.appearanceView;
} else if ([sender.itemIdentifier isEqualToString:@"tabAbout"]) {
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
self.lblAppName.objectValue = infoDict[@"CFBundleName"];
Expand Down
7 changes: 7 additions & 0 deletions baRSS/Preferences/Preferences.xib
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
<action selector="tabClicked:" target="-2" id="MVF-hq-6H4"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="BC213BA1-C1C5-4EBA-8282-769344192482" explicitItemIdentifier="tabAppearance" label="Appearance" paletteLabel="Appearance" tag="-1" image="NSFontPanel" selectable="YES" id="5gP-ck-qVK">
<connections>
<action selector="tabClicked:" target="-2" id="BXs-NU-zQM"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="NSToolbarFlexibleSpaceItem" id="kda-e8-akS"/>
<toolbarItem implicitItemIdentifier="7A0CF54C-C0BA-4E1D-9CD7-39FD39A6BA5A" explicitItemIdentifier="tabAbout" label="About" paletteLabel="About" tag="-1" image="NSInfo" selectable="YES" id="kob-4t-J64">
<connections>
Expand All @@ -48,6 +53,7 @@
<defaultToolbarItems>
<toolbarItem reference="WDq-RJ-C3X"/>
<toolbarItem reference="atT-AS-vmR"/>
<toolbarItem reference="5gP-ck-qVK"/>
<toolbarItem reference="kda-e8-akS"/>
<toolbarItem reference="kob-4t-J64"/>
</defaultToolbarItems>
Expand Down Expand Up @@ -769,6 +775,7 @@ Cg
</objects>
<resources>
<image name="NSApplicationIcon" width="128" height="128"/>
<image name="NSFontPanel" width="32" height="32"/>
<image name="NSInfo" width="32" height="32"/>
<image name="NSPreferencesGeneral" width="32" height="32"/>
<image name="NSUserAccounts" width="32" height="32"/>
Expand Down
5 changes: 4 additions & 1 deletion baRSS/Status Bar Menu/BarMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ - (void)setFeedGroups:(NSArray<FeedGroup*>*)sortedList forMenu:(NSMenu*)menu {
/// Generate items for @c FeedArticles menu.
- (void)setArticles:(NSArray<FeedArticle*>*)sortedList forMenu:(NSMenu*)menu {
[menu insertDefaultHeader];
NSUInteger mc = [UserPrefs articlesInMenuLimit];
NSUInteger mc = 0;
if ([UserPrefs defaultNO:@"feedLimitArticles"]) {
mc = [UserPrefs articlesInMenuLimit];
}
for (FeedArticle *fa in sortedList) {
[menu addItem:[fa newMenuItem]];
if (--mc == 0) // if mc==0 then unsigned int will underflow and turn into INT_MAX
Expand Down

0 comments on commit 55aeea5

Please sign in to comment.