Fix const + PostNotification() + RegisterNotification()
This commit is contained in:
@@ -71,9 +71,7 @@
|
|||||||
url = [url substringFromIndex:2];
|
url = [url substringFromIndex:2];
|
||||||
}
|
}
|
||||||
if ([scheme isEqualToString:@"feed"]) {
|
if ([scheme isEqualToString:@"feed"]) {
|
||||||
[FeedDownload autoDownloadAndParseURL:url successBlock:^{
|
[FeedDownload autoDownloadAndParseURL:url successBlock:nil];
|
||||||
[self reopenPreferencesIfOpen];
|
|
||||||
}];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/// UTI type used for opml files
|
/// UTI type used for opml files
|
||||||
static const NSPasteboardType UTI_OPML = @"org.opml";
|
static NSPasteboardType const UTI_OPML = @"org.opml";
|
||||||
|
|
||||||
|
|
||||||
#pragma mark - NSImageName constants
|
#pragma mark - NSImageName constants
|
||||||
@@ -54,37 +54,45 @@ static NSImageName const RSSImageMenuItemUnread = @"RSSImageMenuItemUnread";
|
|||||||
#pragma mark - NSNotificationName constants
|
#pragma mark - NSNotificationName constants
|
||||||
|
|
||||||
|
|
||||||
|
/// Helper method calls @c (defaultCenter)postNotification:
|
||||||
|
NS_INLINE void PostNotification(NSNotificationName name, id obj) { [[NSNotificationCenter defaultCenter] postNotificationName:name object:obj]; }
|
||||||
|
NS_INLINE void RegisterNotification(NSNotificationName name, SEL action, id observer) { [[NSNotificationCenter defaultCenter] addObserver:observer selector:action name:name object:nil]; }
|
||||||
/**
|
/**
|
||||||
@c notification.object is @c NSNumber of type @c NSUInteger.
|
@c notification.object is @c NSNumber of type @c NSUInteger.
|
||||||
Represents number of feeds that are proccessed in background update. Sends @c 0 when all downloads are finished.
|
Represents number of feeds that are proccessed in background update. Sends @c 0 when all downloads are finished.
|
||||||
*/
|
*/
|
||||||
static const NSNotificationName kNotificationBackgroundUpdateInProgress = @"baRSS-notification-background-update-in-progress";
|
static NSNotificationName const kNotificationBackgroundUpdateInProgress = @"baRSS-notification-background-update-in-progress";
|
||||||
|
/**
|
||||||
|
@c notification.object is @c NSManagedObjectID of type @c FeedGroup.
|
||||||
|
Called whenever a new feed group was created in @c autoDownloadAndParseURL:
|
||||||
|
*/
|
||||||
|
static NSNotificationName const kNotificationGroupInserted = @"baRSS-notification-group-inserted";
|
||||||
/**
|
/**
|
||||||
@c notification.object is @c NSManagedObjectID of type @c Feed.
|
@c notification.object is @c NSManagedObjectID of type @c Feed.
|
||||||
Called whenever download of a feed finished and object was modified (not if statusCode 304).
|
Called whenever download of a feed finished and object was modified (not if statusCode 304).
|
||||||
*/
|
*/
|
||||||
static const NSNotificationName kNotificationFeedUpdated = @"baRSS-notification-feed-updated";
|
static NSNotificationName const kNotificationFeedUpdated = @"baRSS-notification-feed-updated";
|
||||||
/**
|
/**
|
||||||
@c notification.object is @c NSManagedObjectID of type @c Feed.
|
@c notification.object is @c NSManagedObjectID of type @c Feed.
|
||||||
Called whenever the icon attribute of an item was updated.
|
Called whenever the icon attribute of an item was updated.
|
||||||
*/
|
*/
|
||||||
static const NSNotificationName kNotificationFeedIconUpdated = @"baRSS-notification-feed-icon-updated";
|
static NSNotificationName const kNotificationFeedIconUpdated = @"baRSS-notification-feed-icon-updated";
|
||||||
/**
|
/**
|
||||||
@c notification.object is @c NSNumber of type @c BOOL.
|
@c notification.object is @c NSNumber of type @c BOOL.
|
||||||
@c YES if network became reachable. @c NO on connection lost.
|
@c YES if network became reachable. @c NO on connection lost.
|
||||||
*/
|
*/
|
||||||
static const NSNotificationName kNotificationNetworkStatusChanged = @"baRSS-notification-network-status-changed";
|
static NSNotificationName const kNotificationNetworkStatusChanged = @"baRSS-notification-network-status-changed";
|
||||||
/**
|
/**
|
||||||
@c notification.object is @c NSNumber of type @c NSInteger.
|
@c notification.object is @c NSNumber of type @c NSInteger.
|
||||||
Represents a relative change (e.g., negative if items were marked read)
|
Represents a relative change (e.g., negative if items were marked read)
|
||||||
*/
|
*/
|
||||||
static const NSNotificationName kNotificationTotalUnreadCountChanged = @"baRSS-notification-total-unread-count-changed";
|
static NSNotificationName const kNotificationTotalUnreadCountChanged = @"baRSS-notification-total-unread-count-changed";
|
||||||
/**
|
/**
|
||||||
@c notification.object is either @c nil or @c NSNumber of type @c NSInteger.
|
@c notification.object is either @c nil or @c NSNumber of type @c NSInteger.
|
||||||
If new count is known an absoulte number is passed.
|
If new count is known an absoulte number is passed.
|
||||||
Else @c nil if count has to be fetched from core data.
|
Else @c nil if count has to be fetched from core data.
|
||||||
*/
|
*/
|
||||||
static const NSNotificationName kNotificationTotalUnreadCountReset = @"baRSS-notification-total-unread-count-reset";
|
static NSNotificationName const kNotificationTotalUnreadCountReset = @"baRSS-notification-total-unread-count-reset";
|
||||||
|
|
||||||
|
|
||||||
#pragma mark - Internal
|
#pragma mark - Internal
|
||||||
|
|||||||
@@ -97,7 +97,7 @@
|
|||||||
diff += [self insertArticles:localSet withRemoteSet:obj.articles]; // insert new in correct order
|
diff += [self insertArticles:localSet withRemoteSet:obj.articles]; // insert new in correct order
|
||||||
// Get new total article count and post unread-count-change notification
|
// Get new total article count and post unread-count-change notification
|
||||||
if (flag && diff != 0) {
|
if (flag && diff != 0) {
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationTotalUnreadCountChanged object:@(diff)];
|
PostNotification(kNotificationTotalUnreadCountChanged, @(diff));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@
|
|||||||
fa.unread = !fa.unread;
|
fa.unread = !fa.unread;
|
||||||
[StoreCoordinator saveContext:moc andParent:YES];
|
[StoreCoordinator saveContext:moc andParent:YES];
|
||||||
NSNumber *num = (fa.unread ? @+1 : @-1);
|
NSNumber *num = (fa.unread ? @+1 : @-1);
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationTotalUnreadCountChanged object:num];
|
PostNotification(kNotificationTotalUnreadCountChanged, num);
|
||||||
}
|
}
|
||||||
[moc reset];
|
[moc reset];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#import "FeedMeta+CoreDataClass.h"
|
#import "FeedMeta+CoreDataClass.h"
|
||||||
|
|
||||||
static const int32_t kDefaultFeedRefreshInterval = 30 * 60;
|
static int32_t const kDefaultFeedRefreshInterval = 30 * 60;
|
||||||
|
|
||||||
@interface FeedMeta (Ext)
|
@interface FeedMeta (Ext)
|
||||||
// HTTP response
|
// HTTP response
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "DBv1+CoreDataModel.h"
|
#import "DBv1+CoreDataModel.h"
|
||||||
|
|
||||||
static const int dbFileVersion = 1; // update in case database structure changes
|
static int const dbFileVersion = 1; // update in case database structure changes
|
||||||
|
|
||||||
@interface StoreCoordinator : NSObject
|
@interface StoreCoordinator : NSObject
|
||||||
// Managing contexts
|
// Managing contexts
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ NS_INLINE void DrawGradient(CGContextRef c, CGFloat size, NSColor *color) {
|
|||||||
[rgbColor getHue:&h saturation:&s brightness:&b alpha:&a];
|
[rgbColor getHue:&h saturation:&s brightness:&b alpha:&a];
|
||||||
} @catch (NSException *e) {}
|
} @catch (NSException *e) {}
|
||||||
|
|
||||||
static const CGFloat impact = 0.3;
|
static CGFloat const impact = 0.3;
|
||||||
NSColor *darker = [NSColor colorWithHue:h saturation:(s + impact > 1 ? 1 : s + impact) brightness:b alpha:a];
|
NSColor *darker = [NSColor colorWithHue:h saturation:(s + impact > 1 ? 1 : s + impact) brightness:b alpha:a];
|
||||||
NSColor *lighter = [NSColor colorWithHue:h saturation:(s - impact < 0 ? 0 : s - impact) brightness:b alpha:a];
|
NSColor *lighter = [NSColor colorWithHue:h saturation:(s - impact < 0 ? 0 : s - impact) brightness:b alpha:a];
|
||||||
const void* cgColors[] = {
|
const void* cgColors[] = {
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ static BOOL _nextUpdateIsForced = NO;
|
|||||||
}
|
}
|
||||||
[StoreCoordinator saveContext:moc andParent:YES];
|
[StoreCoordinator saveContext:moc andParent:YES];
|
||||||
if (needsNotification)
|
if (needsNotification)
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationFeedUpdated object:oid];
|
PostNotification(kNotificationFeedUpdated, oid);
|
||||||
if (block) block(success);
|
if (block) block(success);
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@@ -353,6 +353,7 @@ static BOOL _nextUpdateIsForced = NO;
|
|||||||
[StoreCoordinator saveContext:moc andParent:YES];
|
[StoreCoordinator saveContext:moc andParent:YES];
|
||||||
[moc reset];
|
[moc reset];
|
||||||
if (successful) {
|
if (successful) {
|
||||||
|
PostNotification(kNotificationGroupInserted, f.group.objectID);
|
||||||
[self scheduleUpdateForUpcomingFeeds];
|
[self scheduleUpdateForUpcomingFeeds];
|
||||||
if (block) block();
|
if (block) block();
|
||||||
}
|
}
|
||||||
@@ -388,7 +389,7 @@ static BOOL _nextUpdateIsForced = NO;
|
|||||||
*/
|
*/
|
||||||
+ (void)batchDownloadFeeds:(NSArray<Feed*> *)list favicons:(BOOL)fav showErrorAlert:(BOOL)alert finally:(nullable os_block_t)block {
|
+ (void)batchDownloadFeeds:(NSArray<Feed*> *)list favicons:(BOOL)fav showErrorAlert:(BOOL)alert finally:(nullable os_block_t)block {
|
||||||
_isUpdating = YES;
|
_isUpdating = YES;
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationBackgroundUpdateInProgress object:@(list.count)];
|
PostNotification(kNotificationBackgroundUpdateInProgress, @(list.count));
|
||||||
dispatch_group_t group = dispatch_group_create();
|
dispatch_group_t group = dispatch_group_create();
|
||||||
for (Feed *f in list) {
|
for (Feed *f in list) {
|
||||||
dispatch_group_enter(group);
|
dispatch_group_enter(group);
|
||||||
@@ -399,7 +400,7 @@ static BOOL _nextUpdateIsForced = NO;
|
|||||||
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
|
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
|
||||||
if (block) block();
|
if (block) block();
|
||||||
_isUpdating = NO;
|
_isUpdating = NO;
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationBackgroundUpdateInProgress object:@(0)];
|
PostNotification(kNotificationBackgroundUpdateInProgress, @(0));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,7 +427,7 @@ static BOOL _nextUpdateIsForced = NO;
|
|||||||
Feed *f = [moc objectWithID:oid];
|
Feed *f = [moc objectWithID:oid];
|
||||||
if (f && [f setIconImage:img]) {
|
if (f && [f setIconImage:img]) {
|
||||||
[StoreCoordinator saveContext:moc andParent:YES];
|
[StoreCoordinator saveContext:moc andParent:YES];
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationFeedIconUpdated object:oid];
|
PostNotification(kNotificationFeedIconUpdated, oid);
|
||||||
}
|
}
|
||||||
if (block) block();
|
if (block) block();
|
||||||
}];
|
}];
|
||||||
@@ -549,7 +550,7 @@ static BOOL _nextUpdateIsForced = NO;
|
|||||||
static void networkReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkConnectionFlags flags, void *object) {
|
static void networkReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkConnectionFlags flags, void *object) {
|
||||||
if (_reachability == NULL) return;
|
if (_reachability == NULL) return;
|
||||||
_isReachable = [FeedDownload hasConnectivity:flags];
|
_isReachable = [FeedDownload hasConnectivity:flags];
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationNetworkStatusChanged object:@(_isReachable)];
|
PostNotification(kNotificationNetworkStatusChanged, @(_isReachable));
|
||||||
if (_isReachable) {
|
if (_isReachable) {
|
||||||
[FeedDownload resumeUpdates];
|
[FeedDownload resumeUpdates];
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#import <QuartzCore/QuartzCore.h>
|
#import <QuartzCore/QuartzCore.h>
|
||||||
|
|
||||||
static const TimeUnitType _values[] = {
|
static TimeUnitType const _values[] = {
|
||||||
TimeUnitYears,
|
TimeUnitYears,
|
||||||
TimeUnitWeeks,
|
TimeUnitWeeks,
|
||||||
TimeUnitDays,
|
TimeUnitDays,
|
||||||
|
|||||||
@@ -22,23 +22,23 @@
|
|||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
/***/ static const CGFloat PAD_WIN = 20; // window padding
|
/***/ static CGFloat const PAD_WIN = 20; // window padding
|
||||||
/***/ static const CGFloat PAD_L = 16;
|
/***/ static CGFloat const PAD_L = 16;
|
||||||
/***/ static const CGFloat PAD_M = 8;
|
/***/ static CGFloat const PAD_M = 8;
|
||||||
/***/ static const CGFloat PAD_S = 4;
|
/***/ static CGFloat const PAD_S = 4;
|
||||||
/***/ static const CGFloat PAD_XS = 2;
|
/***/ static CGFloat const PAD_XS = 2;
|
||||||
|
|
||||||
/***/ static const CGFloat HEIGHT_LABEL = 17;
|
/***/ static CGFloat const HEIGHT_LABEL = 17;
|
||||||
/***/ static const CGFloat HEIGHT_LABEL_SMALL = 14;
|
/***/ static CGFloat const HEIGHT_LABEL_SMALL = 14;
|
||||||
/***/ static const CGFloat HEIGHT_INPUTFIELD = 21;
|
/***/ static CGFloat const HEIGHT_INPUTFIELD = 21;
|
||||||
/***/ static const CGFloat HEIGHT_BUTTON = 21;
|
/***/ static CGFloat const HEIGHT_BUTTON = 21;
|
||||||
/***/ static const CGFloat HEIGHT_INLINEBUTTON = 16;
|
/***/ static CGFloat const HEIGHT_INLINEBUTTON = 16;
|
||||||
/***/ static const CGFloat HEIGHT_POPUP = 21;
|
/***/ static CGFloat const HEIGHT_POPUP = 21;
|
||||||
/***/ static const CGFloat HEIGHT_SPINNER = 16;
|
/***/ static CGFloat const HEIGHT_SPINNER = 16;
|
||||||
/***/ static const CGFloat HEIGHT_CHECKBOX = 14;
|
/***/ static CGFloat const HEIGHT_CHECKBOX = 14;
|
||||||
|
|
||||||
/// Static variable to calculate origin center coordinate in its @c superview. The value of this var isn't used.
|
/// Static variable to calculate origin center coordinate in its @c superview. The value of this var isn't used.
|
||||||
static const CGFloat CENTER = -0.015625;
|
static CGFloat const CENTER = -0.015625;
|
||||||
|
|
||||||
/// Calculate @c origin.y going down from the top border of its @c superview
|
/// Calculate @c origin.y going down from the top border of its @c superview
|
||||||
NS_INLINE CGFloat YFromTop(NSView *view) { return NSHeight(view.superview.frame) - NSMinY(view.frame) - view.alignmentRectInsets.bottom; }
|
NS_INLINE CGFloat YFromTop(NSView *view) { return NSHeight(view.superview.frame) - NSMinY(view.frame) - view.alignmentRectInsets.bottom; }
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>10141</string>
|
<string>10158</string>
|
||||||
<key>LSApplicationCategoryType</key>
|
<key>LSApplicationCategoryType</key>
|
||||||
<string>public.app-category.news</string>
|
<string>public.app-category.news</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
|||||||
@@ -30,8 +30,8 @@
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
/***/ static const CGFloat IconSize = 18;
|
/***/ static CGFloat const IconSize = 18;
|
||||||
/***/ static const CGFloat colWidth = (IconSize + PAD_M); // checkbox column width
|
/***/ static CGFloat const colWidth = (IconSize + PAD_M); // checkbox column width
|
||||||
|
|
||||||
|
|
||||||
@implementation SettingsAppearanceView
|
@implementation SettingsAppearanceView
|
||||||
@@ -63,8 +63,8 @@
|
|||||||
|
|
||||||
/// Create new entry with 1-3 checkboxes and a descriptive label
|
/// Create new entry with 1-3 checkboxes and a descriptive label
|
||||||
- (NSTextField*)entry:(char*)m label:(NSString*)text {
|
- (NSTextField*)entry:(char*)m label:(NSString*)text {
|
||||||
static const char* scope[] = { "global", "group", "feed" };
|
static char* const scope[] = { "global", "group", "feed" };
|
||||||
static const char* ident[] = { "TintMenuBarIcon", "UpdateAll", "OpenUnread", "MarkRead", "MarkUnread", "UnreadCount", "TickMark", "ShortNames", "LimitArticles" };
|
static char* const ident[] = { "TintMenuBarIcon", "UpdateAll", "OpenUnread", "MarkRead", "MarkUnread", "UnreadCount", "TickMark", "ShortNames", "LimitArticles" };
|
||||||
CGFloat y = PAD_WIN + IconSize + PAD_S + self.row * (PAD_S + HEIGHT_LABEL);
|
CGFloat y = PAD_WIN + IconSize + PAD_S + self.row * (PAD_S + HEIGHT_LABEL);
|
||||||
|
|
||||||
// Add checkboxes: row 0 - 8, col 0 - 2
|
// Add checkboxes: row 0 - 8, col 0 - 2
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
||||||
|
|
||||||
CGFloat x = NSWidth(labels.frame) + PAD_S;
|
CGFloat x = NSWidth(labels.frame) + PAD_S;
|
||||||
static const CGFloat rowHeight = PAD_S + HEIGHT_INPUTFIELD;
|
static CGFloat const rowHeight = PAD_S + HEIGHT_INPUTFIELD;
|
||||||
[labels placeIn:self x:0 yTop:0];
|
[labels placeIn:self x:0 yTop:0];
|
||||||
|
|
||||||
// 1. row
|
// 1. row
|
||||||
|
|||||||
@@ -48,9 +48,10 @@
|
|||||||
- (void)viewDidLoad {
|
- (void)viewDidLoad {
|
||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
// Register for notifications
|
// Register for notifications
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(feedUpdated:) name:kNotificationFeedUpdated object:nil];
|
RegisterNotification(kNotificationFeedUpdated, @selector(feedUpdated:), self);
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(feedUpdated:) name:kNotificationFeedIconUpdated object:nil];
|
RegisterNotification(kNotificationFeedIconUpdated, @selector(feedUpdated:), self);
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateInProgress:) name:kNotificationBackgroundUpdateInProgress object:nil];
|
RegisterNotification(kNotificationGroupInserted, @selector(groupInserted:), self);
|
||||||
|
RegisterNotification(kNotificationBackgroundUpdateInProgress, @selector(updateInProgress:), self);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
@@ -162,6 +163,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Callback method fired when feed is inserted via a 'feed://' url
|
||||||
|
- (void)groupInserted:(NSNotification*)notify {
|
||||||
|
[self.dataStore fetch:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#pragma mark - Activity Spinner & Status Info
|
#pragma mark - Activity Spinner & Status Info
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
- (void)fixCache:(NSButton *)sender {
|
- (void)fixCache:(NSButton *)sender {
|
||||||
NSUInteger deleted = [StoreCoordinator deleteUnreferenced];
|
NSUInteger deleted = [StoreCoordinator deleteUnreferenced];
|
||||||
[StoreCoordinator restoreFeedIndexPaths];
|
[StoreCoordinator restoreFeedIndexPaths];
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationTotalUnreadCountReset object:nil];
|
PostNotification(kNotificationTotalUnreadCountReset, nil);
|
||||||
// show only if >0, but hey, this button will vanish anyway ...
|
// show only if >0, but hey, this button will vanish anyway ...
|
||||||
NSAlert *alert = [[NSAlert alloc] init];
|
NSAlert *alert = [[NSAlert alloc] init];
|
||||||
alert.messageText = [NSString stringWithFormat:@"Removed %lu unreferenced core data entries.", deleted];
|
alert.messageText = [NSString stringWithFormat:@"Removed %lu unreferenced core data entries.", deleted];
|
||||||
|
|||||||
@@ -31,9 +31,9 @@
|
|||||||
|
|
||||||
/// Designated initializer. 'Done' and 'Cancel' buttons will be added automatically.
|
/// Designated initializer. 'Done' and 'Cancel' buttons will be added automatically.
|
||||||
- (instancetype)initWithView:(NSView*)content {
|
- (instancetype)initWithView:(NSView*)content {
|
||||||
static const NSInteger minWidth = 320;
|
static NSInteger const minWidth = 320;
|
||||||
static const NSInteger maxWidth = 1200;
|
static NSInteger const maxWidth = 1200;
|
||||||
static const CGFloat contentOffsetY = PAD_WIN + HEIGHT_BUTTON + PAD_L;
|
static CGFloat const contentOffsetY = PAD_WIN + HEIGHT_BUTTON + PAD_L;
|
||||||
|
|
||||||
NSInteger w = [[NSUserDefaults standardUserDefaults] integerForKey:@"modalSheetWidth"];
|
NSInteger w = [[NSUserDefaults standardUserDefaults] integerForKey:@"modalSheetWidth"];
|
||||||
if (w < minWidth) w = minWidth;
|
if (w < minWidth) w = minWidth;
|
||||||
|
|||||||
@@ -45,8 +45,8 @@
|
|||||||
// TODO: move unread counts to status item and keep in sync when changing feeds in preferences
|
// TODO: move unread counts to status item and keep in sync when changing feeds in preferences
|
||||||
self.unreadMap = [[MapUnreadTotal alloc] initWithCoreData: [StoreCoordinator countAggregatedUnread]];
|
self.unreadMap = [[MapUnreadTotal alloc] initWithCoreData: [StoreCoordinator countAggregatedUnread]];
|
||||||
// Register for notifications
|
// Register for notifications
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(feedUpdated:) name:kNotificationFeedUpdated object:nil];
|
RegisterNotification(kNotificationFeedUpdated, @selector(feedUpdated:), self);
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(feedIconUpdated:) name:kNotificationFeedIconUpdated object:nil];
|
RegisterNotification(kNotificationFeedIconUpdated, @selector(feedIconUpdated:), self);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,9 +53,9 @@
|
|||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mainMenuWillOpen) name:NSMenuDidBeginTrackingNotification object:self.statusItem.menu];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mainMenuWillOpen) name:NSMenuDidBeginTrackingNotification object:self.statusItem.menu];
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mainMenuDidClose) name:NSMenuDidEndTrackingNotification object:self.statusItem.menu];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mainMenuDidClose) name:NSMenuDidEndTrackingNotification object:self.statusItem.menu];
|
||||||
// Some icon unread count notification callback methods
|
// Some icon unread count notification callback methods
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkChanged:) name:kNotificationNetworkStatusChanged object:nil];
|
RegisterNotification(kNotificationNetworkStatusChanged, @selector(networkChanged:), self);
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(unreadCountChanged:) name:kNotificationTotalUnreadCountChanged object:nil];
|
RegisterNotification(kNotificationTotalUnreadCountChanged, @selector(unreadCountChanged:), self);
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(unreadCountReset:) name:kNotificationTotalUnreadCountReset object:nil];
|
RegisterNotification(kNotificationTotalUnreadCountReset, @selector(unreadCountReset:), self);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -151,8 +151,8 @@ typedef NS_ENUM(NSInteger, MenuItemTag) {
|
|||||||
|
|
||||||
/// Check user preferences for preferred display style.
|
/// Check user preferences for preferred display style.
|
||||||
- (BOOL)allowDisplayOfHeaderItem:(MenuItemTag)tag {
|
- (BOOL)allowDisplayOfHeaderItem:(MenuItemTag)tag {
|
||||||
static const char * A[] = {"", "global", "feed", "group"};
|
static char* const A[] = {"", "global", "feed", "group"};
|
||||||
static const char * B[] = {"", "MarkRead", "MarkUnread", "OpenUnread"};
|
static char* const B[] = {"", "MarkRead", "MarkUnread", "OpenUnread"};
|
||||||
int idx = (self.isMainMenu ? 1 : (self.isFeedMenu ? 2 : 3));
|
int idx = (self.isMainMenu ? 1 : (self.isFeedMenu ? 2 : 3));
|
||||||
return [UserPrefs defaultYES:[NSString stringWithFormat:@"%s%s", A[idx], B[tag & 3]]]; // first 2 bits
|
return [UserPrefs defaultYES:[NSString stringWithFormat:@"%s%s", A[idx], B[tag & 3]]]; // first 2 bits
|
||||||
}
|
}
|
||||||
@@ -210,7 +210,7 @@ typedef NS_ENUM(NSInteger, MenuItemTag) {
|
|||||||
[StoreCoordinator saveContext:moc andParent:YES];
|
[StoreCoordinator saveContext:moc andParent:YES];
|
||||||
[moc reset];
|
[moc reset];
|
||||||
NSNumber *num = [NSNumber numberWithInteger: (markRead ? -1 : +1) * (NSInteger)list.count ];
|
NSNumber *num = [NSNumber numberWithInteger: (markRead ? -1 : +1) * (NSInteger)list.count ];
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationTotalUnreadCountChanged object:num];
|
PostNotification(kNotificationTotalUnreadCountChanged, num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user