replaced initial nib with direct code call
This commit is contained in:
@@ -20,9 +20,7 @@
|
|||||||
546FC44421189975007CC3A3 /* SettingsGeneral.xib in Resources */ = {isa = PBXBuildFile; fileRef = 546FC44221189975007CC3A3 /* SettingsGeneral.xib */; };
|
546FC44421189975007CC3A3 /* SettingsGeneral.xib in Resources */ = {isa = PBXBuildFile; fileRef = 546FC44221189975007CC3A3 /* SettingsGeneral.xib */; };
|
||||||
546FC4472118A8E6007CC3A3 /* Preferences.xib in Resources */ = {isa = PBXBuildFile; fileRef = 546FC4462118A8E6007CC3A3 /* Preferences.xib */; };
|
546FC4472118A8E6007CC3A3 /* Preferences.xib in Resources */ = {isa = PBXBuildFile; fileRef = 546FC4462118A8E6007CC3A3 /* Preferences.xib */; };
|
||||||
5477D34E21233C62002BA27F /* FeedConfig+Ext.m in Sources */ = {isa = PBXBuildFile; fileRef = 5477D34D21233C62002BA27F /* FeedConfig+Ext.m */; };
|
5477D34E21233C62002BA27F /* FeedConfig+Ext.m in Sources */ = {isa = PBXBuildFile; fileRef = 5477D34D21233C62002BA27F /* FeedConfig+Ext.m */; };
|
||||||
54ACC28121061B3B0020715F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC28021061B3B0020715F /* AppDelegate.m */; };
|
|
||||||
54ACC28621061B3C0020715F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 54ACC28521061B3C0020715F /* Assets.xcassets */; };
|
54ACC28621061B3C0020715F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 54ACC28521061B3C0020715F /* Assets.xcassets */; };
|
||||||
54ACC28921061B3C0020715F /* Main.xib in Resources */ = {isa = PBXBuildFile; fileRef = 54ACC28721061B3C0020715F /* Main.xib */; };
|
|
||||||
54ACC28C21061B3C0020715F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC28B21061B3C0020715F /* main.m */; };
|
54ACC28C21061B3C0020715F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC28B21061B3C0020715F /* main.m */; };
|
||||||
54ACC29521061E270020715F /* FeedDownload.m in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC29421061E270020715F /* FeedDownload.m */; };
|
54ACC29521061E270020715F /* FeedDownload.m in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC29421061E270020715F /* FeedDownload.m */; };
|
||||||
54ACC29821061FBA0020715F /* Preferences.m in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC29721061FBA0020715F /* Preferences.m */; };
|
54ACC29821061FBA0020715F /* Preferences.m in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC29721061FBA0020715F /* Preferences.m */; };
|
||||||
@@ -55,11 +53,8 @@
|
|||||||
5477D34C21233C62002BA27F /* FeedConfig+Ext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FeedConfig+Ext.h"; sourceTree = "<group>"; };
|
5477D34C21233C62002BA27F /* FeedConfig+Ext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FeedConfig+Ext.h"; sourceTree = "<group>"; };
|
||||||
5477D34D21233C62002BA27F /* FeedConfig+Ext.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "FeedConfig+Ext.m"; sourceTree = "<group>"; };
|
5477D34D21233C62002BA27F /* FeedConfig+Ext.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "FeedConfig+Ext.m"; sourceTree = "<group>"; };
|
||||||
54ACC27C21061B3B0020715F /* baRSS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = baRSS.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
54ACC27C21061B3B0020715F /* baRSS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = baRSS.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
54ACC27F21061B3B0020715F /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
|
||||||
54ACC28021061B3B0020715F /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
|
||||||
54ACC28321061B3B0020715F /* DBv1.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = DBv1.xcdatamodel; sourceTree = "<group>"; };
|
54ACC28321061B3B0020715F /* DBv1.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = DBv1.xcdatamodel; sourceTree = "<group>"; };
|
||||||
54ACC28521061B3C0020715F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
54ACC28521061B3C0020715F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
54ACC28821061B3C0020715F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/Main.xib; sourceTree = "<group>"; };
|
|
||||||
54ACC28A21061B3C0020715F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
54ACC28A21061B3C0020715F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
54ACC28B21061B3C0020715F /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
54ACC28B21061B3C0020715F /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||||
54ACC29321061E270020715F /* FeedDownload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FeedDownload.h; sourceTree = "<group>"; };
|
54ACC29321061E270020715F /* FeedDownload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FeedDownload.h; sourceTree = "<group>"; };
|
||||||
@@ -155,8 +150,6 @@
|
|||||||
549369F421091E6D001AF895 /* python */,
|
549369F421091E6D001AF895 /* python */,
|
||||||
544B011B2114EE9100386E5C /* AppHook.h */,
|
544B011B2114EE9100386E5C /* AppHook.h */,
|
||||||
544B011C2114EE9100386E5C /* AppHook.m */,
|
544B011C2114EE9100386E5C /* AppHook.m */,
|
||||||
54ACC27F21061B3B0020715F /* AppDelegate.h */,
|
|
||||||
54ACC28021061B3B0020715F /* AppDelegate.m */,
|
|
||||||
54FE73D1212316CD003EAC65 /* BarMenu.h */,
|
54FE73D1212316CD003EAC65 /* BarMenu.h */,
|
||||||
54FE73D2212316CD003EAC65 /* BarMenu.m */,
|
54FE73D2212316CD003EAC65 /* BarMenu.m */,
|
||||||
54FE73CE21220DEC003EAC65 /* StoreCoordinator.h */,
|
54FE73CE21220DEC003EAC65 /* StoreCoordinator.h */,
|
||||||
@@ -167,7 +160,6 @@
|
|||||||
54209E932117325100F3B5EF /* DrawImage.m */,
|
54209E932117325100F3B5EF /* DrawImage.m */,
|
||||||
546FC44D2118B357007CC3A3 /* Preferences */,
|
546FC44D2118B357007CC3A3 /* Preferences */,
|
||||||
54ACC28521061B3C0020715F /* Assets.xcassets */,
|
54ACC28521061B3C0020715F /* Assets.xcassets */,
|
||||||
54ACC28721061B3C0020715F /* Main.xib */,
|
|
||||||
54ACC28A21061B3C0020715F /* Info.plist */,
|
54ACC28A21061B3C0020715F /* Info.plist */,
|
||||||
54ACC28B21061B3C0020715F /* main.m */,
|
54ACC28B21061B3C0020715F /* main.m */,
|
||||||
54ACC28221061B3B0020715F /* DBv1.xcdatamodeld */,
|
54ACC28221061B3B0020715F /* DBv1.xcdatamodeld */,
|
||||||
@@ -261,7 +253,6 @@
|
|||||||
546FC43F21188C78007CC3A3 /* SettingsFeeds.xib in Resources */,
|
546FC43F21188C78007CC3A3 /* SettingsFeeds.xib in Resources */,
|
||||||
544FBD4921064DF0008A260C /* feedparser521.py in Resources */,
|
544FBD4921064DF0008A260C /* feedparser521.py in Resources */,
|
||||||
544FBD4721064B2F008A260C /* getFeed.py in Resources */,
|
544FBD4721064B2F008A260C /* getFeed.py in Resources */,
|
||||||
54ACC28921061B3C0020715F /* Main.xib in Resources */,
|
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -278,7 +269,6 @@
|
|||||||
54ACC29521061E270020715F /* FeedDownload.m in Sources */,
|
54ACC29521061E270020715F /* FeedDownload.m in Sources */,
|
||||||
5477D34E21233C62002BA27F /* FeedConfig+Ext.m in Sources */,
|
5477D34E21233C62002BA27F /* FeedConfig+Ext.m in Sources */,
|
||||||
54ACC28C21061B3C0020715F /* main.m in Sources */,
|
54ACC28C21061B3C0020715F /* main.m in Sources */,
|
||||||
54ACC28121061B3B0020715F /* AppDelegate.m in Sources */,
|
|
||||||
54FE73D3212316CD003EAC65 /* BarMenu.m in Sources */,
|
54FE73D3212316CD003EAC65 /* BarMenu.m in Sources */,
|
||||||
544B011A2114B41200386E5C /* ModalSheet.m in Sources */,
|
544B011A2114B41200386E5C /* ModalSheet.m in Sources */,
|
||||||
54ACC29821061FBA0020715F /* Preferences.m in Sources */,
|
54ACC29821061FBA0020715F /* Preferences.m in Sources */,
|
||||||
@@ -292,17 +282,6 @@
|
|||||||
};
|
};
|
||||||
/* End PBXSourcesBuildPhase section */
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXVariantGroup section */
|
|
||||||
54ACC28721061B3C0020715F /* Main.xib */ = {
|
|
||||||
isa = PBXVariantGroup;
|
|
||||||
children = (
|
|
||||||
54ACC28821061B3C0020715F /* Base */,
|
|
||||||
);
|
|
||||||
name = Main.xib;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
/* End PBXVariantGroup section */
|
|
||||||
|
|
||||||
/* Begin XCBuildConfiguration section */
|
/* Begin XCBuildConfiguration section */
|
||||||
54ACC28E21061B3C0020715F /* Debug */ = {
|
54ACC28E21061B3C0020715F /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
//
|
|
||||||
// The MIT License (MIT)
|
|
||||||
// Copyright (c) 2018 Oleg Geier
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
|
||||||
// the Software without restriction, including without limitation the rights to
|
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
||||||
// of the Software, and to permit persons to whom the Software is furnished to do
|
|
||||||
// so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
#import <CoreData/CoreData.h>
|
|
||||||
|
|
||||||
@interface AppDelegate : NSObject <NSApplicationDelegate>
|
|
||||||
@property (readonly, strong) NSPersistentContainer *persistentContainer;
|
|
||||||
- (IBAction)saveAction:(id)sender;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
//
|
|
||||||
// The MIT License (MIT)
|
|
||||||
// Copyright (c) 2018 Oleg Geier
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
|
||||||
// the Software without restriction, including without limitation the rights to
|
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
||||||
// of the Software, and to permit persons to whom the Software is furnished to do
|
|
||||||
// so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
|
|
||||||
#import "AppDelegate.h"
|
|
||||||
#import "PyHandler.h"
|
|
||||||
#import "BarMenu.h"
|
|
||||||
|
|
||||||
@interface AppDelegate ()
|
|
||||||
@property (strong) BarMenu *barMenu;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation AppDelegate
|
|
||||||
|
|
||||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
|
|
||||||
self.barMenu = [BarMenu new];
|
|
||||||
[PyHandler prepare];
|
|
||||||
printf("up and running\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)applicationWillTerminate:(NSNotification *)aNotification {
|
|
||||||
[PyHandler shutdown];
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - Core Data stack
|
|
||||||
|
|
||||||
@synthesize persistentContainer = _persistentContainer;
|
|
||||||
|
|
||||||
- (NSPersistentContainer *)persistentContainer {
|
|
||||||
// The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it.
|
|
||||||
@synchronized (self) {
|
|
||||||
if (_persistentContainer == nil) {
|
|
||||||
_persistentContainer = [[NSPersistentContainer alloc] initWithName:@"DBv1"];
|
|
||||||
[_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) {
|
|
||||||
if (error != nil) {
|
|
||||||
NSLog(@"Couldn't read NSPersistentContainer: %@, %@", error, error.userInfo);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
}];
|
|
||||||
NSUndoManager *um = [[NSUndoManager alloc] init];
|
|
||||||
um.groupsByEvent = NO;
|
|
||||||
um.levelsOfUndo = 30;
|
|
||||||
_persistentContainer.viewContext.undoManager = um;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return _persistentContainer;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - Core Data Saving and Undo support
|
|
||||||
|
|
||||||
- (IBAction)saveAction:(id)sender {
|
|
||||||
// Performs the save action for the application, which is to send the save: message to the application's managed object context. Any encountered errors are presented to the user.
|
|
||||||
NSManagedObjectContext *context = self.persistentContainer.viewContext;
|
|
||||||
|
|
||||||
if (![context commitEditing]) {
|
|
||||||
NSLog(@"%@:%@ unable to commit editing before saving", [self class], NSStringFromSelector(_cmd));
|
|
||||||
}
|
|
||||||
|
|
||||||
NSError *error = nil;
|
|
||||||
if (context.hasChanges && ![context save:&error]) {
|
|
||||||
// Customize this code block to include application-specific recovery steps.
|
|
||||||
[[NSApplication sharedApplication] presentError:error];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)window {
|
|
||||||
// Returns the NSUndoManager for the application. In this case, the manager returned is that of the managed object context for the application.
|
|
||||||
return self.persistentContainer.viewContext.undoManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
|
|
||||||
// Save changes in the application's managed object context before the application terminates.
|
|
||||||
NSManagedObjectContext *context = self.persistentContainer.viewContext;
|
|
||||||
|
|
||||||
if (![context commitEditing]) {
|
|
||||||
NSLog(@"%@:%@ unable to commit editing to terminate", [self class], NSStringFromSelector(_cmd));
|
|
||||||
return NSTerminateCancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!context.hasChanges) {
|
|
||||||
return NSTerminateNow;
|
|
||||||
}
|
|
||||||
|
|
||||||
NSError *error = nil;
|
|
||||||
if (![context save:&error]) {
|
|
||||||
|
|
||||||
// Customize this code block to include application-specific recovery steps.
|
|
||||||
BOOL result = [sender presentError:error];
|
|
||||||
if (result) {
|
|
||||||
return NSTerminateCancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
NSString *question = NSLocalizedString(@"Could not save changes while quitting. Quit anyway?", @"Quit without saves error question message");
|
|
||||||
NSString *info = NSLocalizedString(@"Quitting now will lose any changes you have made since the last successful save", @"Quit without saves error question info");
|
|
||||||
NSString *quitButton = NSLocalizedString(@"Quit anyway", @"Quit anyway button title");
|
|
||||||
NSString *cancelButton = NSLocalizedString(@"Cancel", @"Cancel button title");
|
|
||||||
NSAlert *alert = [[NSAlert alloc] init];
|
|
||||||
[alert setMessageText:question];
|
|
||||||
[alert setInformativeText:info];
|
|
||||||
[alert addButtonWithTitle:quitButton];
|
|
||||||
[alert addButtonWithTitle:cancelButton];
|
|
||||||
|
|
||||||
NSInteger answer = [alert runModal];
|
|
||||||
|
|
||||||
if (answer == NSAlertSecondButtonReturn) {
|
|
||||||
return NSTerminateCancel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NSTerminateNow;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -21,7 +21,9 @@
|
|||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import <CoreData/CoreData.h>
|
||||||
|
|
||||||
@interface AppHook : NSApplication
|
@interface AppHook : NSApplication <NSApplicationDelegate>
|
||||||
|
@property (readonly, strong) NSPersistentContainer *persistentContainer;
|
||||||
|
- (IBAction)saveAction:(id)sender;
|
||||||
@end
|
@end
|
||||||
|
|||||||
126
baRSS/AppHook.m
126
baRSS/AppHook.m
@@ -21,10 +21,133 @@
|
|||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
#import "AppHook.h"
|
#import "AppHook.h"
|
||||||
|
#import "PyHandler.h"
|
||||||
|
#import "BarMenu.h"
|
||||||
|
|
||||||
|
@interface AppHook()
|
||||||
|
@property (strong) BarMenu *barMenu;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation AppHook
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
self = [super init];
|
||||||
|
self.delegate = self;
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
|
||||||
|
self.barMenu = [BarMenu new];
|
||||||
|
[PyHandler prepare];
|
||||||
|
printf("up and running\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)applicationWillTerminate:(NSNotification *)aNotification {
|
||||||
|
[PyHandler shutdown];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction)closePreferences:(id)sender {
|
||||||
|
NSLog(@"closing in %@", sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma mark - Core Data stack
|
||||||
|
|
||||||
|
|
||||||
|
@synthesize persistentContainer = _persistentContainer;
|
||||||
|
|
||||||
|
- (NSPersistentContainer *)persistentContainer {
|
||||||
|
// The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it.
|
||||||
|
@synchronized (self) {
|
||||||
|
if (_persistentContainer == nil) {
|
||||||
|
_persistentContainer = [[NSPersistentContainer alloc] initWithName:@"DBv1"];
|
||||||
|
[_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) {
|
||||||
|
if (error != nil) {
|
||||||
|
NSLog(@"Couldn't read NSPersistentContainer: %@, %@", error, error.userInfo);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
NSUndoManager *um = [[NSUndoManager alloc] init];
|
||||||
|
um.groupsByEvent = NO;
|
||||||
|
um.levelsOfUndo = 30;
|
||||||
|
_persistentContainer.viewContext.undoManager = um;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _persistentContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma mark - Core Data Saving and Undo support
|
||||||
|
|
||||||
|
|
||||||
|
- (IBAction)saveAction:(id)sender {
|
||||||
|
// Performs the save action for the application, which is to send the save: message to the application's managed object context. Any encountered errors are presented to the user.
|
||||||
|
NSManagedObjectContext *context = self.persistentContainer.viewContext;
|
||||||
|
|
||||||
|
if (![context commitEditing]) {
|
||||||
|
NSLog(@"%@:%@ unable to commit editing before saving", [self class], NSStringFromSelector(_cmd));
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *error = nil;
|
||||||
|
if (context.hasChanges && ![context save:&error]) {
|
||||||
|
// Customize this code block to include application-specific recovery steps.
|
||||||
|
[[NSApplication sharedApplication] presentError:error];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)window {
|
||||||
|
// Returns the NSUndoManager for the application. In this case, the manager returned is that of the managed object context for the application.
|
||||||
|
return self.persistentContainer.viewContext.undoManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
|
||||||
|
// Save changes in the application's managed object context before the application terminates.
|
||||||
|
NSManagedObjectContext *context = self.persistentContainer.viewContext;
|
||||||
|
|
||||||
|
if (![context commitEditing]) {
|
||||||
|
NSLog(@"%@:%@ unable to commit editing to terminate", [self class], NSStringFromSelector(_cmd));
|
||||||
|
return NSTerminateCancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!context.hasChanges) {
|
||||||
|
return NSTerminateNow;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *error = nil;
|
||||||
|
if (![context save:&error]) {
|
||||||
|
|
||||||
|
// Customize this code block to include application-specific recovery steps.
|
||||||
|
BOOL result = [sender presentError:error];
|
||||||
|
if (result) {
|
||||||
|
return NSTerminateCancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *question = NSLocalizedString(@"Could not save changes while quitting. Quit anyway?", @"Quit without saves error question message");
|
||||||
|
NSString *info = NSLocalizedString(@"Quitting now will lose any changes you have made since the last successful save", @"Quit without saves error question info");
|
||||||
|
NSString *quitButton = NSLocalizedString(@"Quit anyway", @"Quit anyway button title");
|
||||||
|
NSString *cancelButton = NSLocalizedString(@"Cancel", @"Cancel button title");
|
||||||
|
NSAlert *alert = [[NSAlert alloc] init];
|
||||||
|
[alert setMessageText:question];
|
||||||
|
[alert setInformativeText:info];
|
||||||
|
[alert addButtonWithTitle:quitButton];
|
||||||
|
[alert addButtonWithTitle:cancelButton];
|
||||||
|
|
||||||
|
NSInteger answer = [alert runModal];
|
||||||
|
|
||||||
|
if (answer == NSAlertSecondButtonReturn) {
|
||||||
|
return NSTerminateCancel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NSTerminateNow;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma mark - Event Handling, Forward Send Key Down Events
|
||||||
|
|
||||||
|
|
||||||
static NSEventModifierFlags fnKeyFlags = NSEventModifierFlagShift | NSEventModifierFlagControl | NSEventModifierFlagOption | NSEventModifierFlagCommand | NSEventModifierFlagFunction;
|
static NSEventModifierFlags fnKeyFlags = NSEventModifierFlagShift | NSEventModifierFlagControl | NSEventModifierFlagOption | NSEventModifierFlagCommand | NSEventModifierFlagFunction;
|
||||||
|
|
||||||
@implementation AppHook
|
|
||||||
- (void) sendEvent:(NSEvent *)event {
|
- (void) sendEvent:(NSEvent *)event {
|
||||||
if ([event type] == NSEventTypeKeyDown) {
|
if ([event type] == NSEventTypeKeyDown) {
|
||||||
if (!event.characters || event.characters.length == 0) {
|
if (!event.characters || event.characters.length == 0) {
|
||||||
@@ -60,4 +183,5 @@ static NSEventModifierFlags fnKeyFlags = NSEventModifierFlagShift | NSEventModif
|
|||||||
}
|
}
|
||||||
[super sendEvent:event];
|
[super sendEvent:event];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14113" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
|
||||||
<dependencies>
|
|
||||||
<deployment identifier="macosx"/>
|
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14113"/>
|
|
||||||
</dependencies>
|
|
||||||
<objects>
|
|
||||||
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
|
|
||||||
<connections>
|
|
||||||
<outlet property="delegate" destination="Voe-Tx-rLC" id="GzC-gU-4Uq"/>
|
|
||||||
</connections>
|
|
||||||
</customObject>
|
|
||||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
|
||||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
|
||||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate"/>
|
|
||||||
</objects>
|
|
||||||
</document>
|
|
||||||
@@ -2,33 +2,33 @@
|
|||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
<key>LSMultipleInstancesProhibited</key>
|
||||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
<true/>
|
||||||
<key>CFBundleExecutable</key>
|
|
||||||
<string>$(EXECUTABLE_NAME)</string>
|
|
||||||
<key>CFBundleIconFile</key>
|
|
||||||
<string></string>
|
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
|
||||||
<string>6.0</string>
|
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>$(PRODUCT_NAME)</string>
|
<string>$(PRODUCT_NAME)</string>
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
<string>APPL</string>
|
<string>6.0</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
|
||||||
<string>1.0</string>
|
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1</string>
|
<string>1</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
<key>LSUIElement</key>
|
|
||||||
<true/>
|
|
||||||
<key>NSHumanReadableCopyright</key>
|
|
||||||
<string>Copyright © 2018 relikd. All rights reserved.</string>
|
|
||||||
<key>NSMainNibFile</key>
|
|
||||||
<string>Main</string>
|
|
||||||
<key>NSPrincipalClass</key>
|
<key>NSPrincipalClass</key>
|
||||||
<string>AppHook</string>
|
<string>AppHook</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string></string>
|
||||||
|
<key>LSUIElement</key>
|
||||||
|
<true/>
|
||||||
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
<string>Copyright © 2018 relikd. All rights reserved.</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
#import "SettingsFeeds.h"
|
#import "SettingsFeeds.h"
|
||||||
#import "AppDelegate.h"
|
#import "AppHook.h"
|
||||||
#import "FeedConfig+Ext.h"
|
#import "FeedConfig+Ext.h"
|
||||||
#import "ModalSheet.h"
|
#import "ModalSheet.h"
|
||||||
#import "ModalFeedEdit.h"
|
#import "ModalFeedEdit.h"
|
||||||
@@ -43,7 +43,7 @@ static NSString *dragNodeType = @"baRSS-feed-drag";
|
|||||||
|
|
||||||
- (void)viewDidLoad {
|
- (void)viewDidLoad {
|
||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
self.dataStore.managedObjectContext = [(AppDelegate*)[NSApp delegate] persistentContainer].viewContext;
|
self.dataStore.managedObjectContext = [(AppHook*)NSApp persistentContainer].viewContext;
|
||||||
self.undoManager = self.dataStore.managedObjectContext.undoManager;
|
self.undoManager = self.dataStore.managedObjectContext.undoManager;
|
||||||
[self.outlineView registerForDraggedTypes:[NSArray arrayWithObject:dragNodeType]];
|
[self.outlineView registerForDraggedTypes:[NSArray arrayWithObject:dragNodeType]];
|
||||||
[self.dataStore setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"sortIndex" ascending:YES]]];
|
[self.dataStore setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"sortIndex" ascending:YES]]];
|
||||||
|
|||||||
@@ -21,16 +21,16 @@
|
|||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
#import "StoreCoordinator.h"
|
#import "StoreCoordinator.h"
|
||||||
#import "AppDelegate.h"
|
#import "AppHook.h"
|
||||||
|
|
||||||
@implementation StoreCoordinator
|
@implementation StoreCoordinator
|
||||||
|
|
||||||
+ (NSManagedObjectContext*)getContext {
|
+ (NSManagedObjectContext*)getContext {
|
||||||
return [(AppDelegate*)[NSApp delegate] persistentContainer].viewContext;
|
return [(AppHook*)NSApp persistentContainer].viewContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void)save {
|
+ (void)save {
|
||||||
[(AppDelegate*)[NSApp delegate] saveAction:nil];
|
[(AppHook*)NSApp saveAction:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void)deleteUnreferencedFeeds {
|
+ (void)deleteUnreferencedFeeds {
|
||||||
|
|||||||
@@ -21,7 +21,9 @@
|
|||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import "AppHook.h"
|
||||||
|
|
||||||
int main(int argc, const char * argv[]) {
|
int main(int argc, const char * argv[]) {
|
||||||
return NSApplicationMain(argc, argv);
|
[[AppHook sharedApplication] run];
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user