mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-02 20:16:54 +01:00
Add Inspector to RSCore. Show/hide inspector via Info command in Window menu.
This commit is contained in:
parent
1e713e3bfd
commit
1d2fe4623b
@ -31,6 +31,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations {
|
||||
var addFeedController: AddFeedController?
|
||||
var addFolderWindowController: AddFolderWindowController?
|
||||
var keyboardShortcutsWindowController: WebViewWindowController?
|
||||
var inspectorWindowController: InspectorWindowController?
|
||||
let log = Log()
|
||||
let themeLoader = VSThemeLoader()
|
||||
private let appNewsURLString = "https://ranchero.com/evergreen/feed.json"
|
||||
@ -247,7 +248,21 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations {
|
||||
}
|
||||
keyboardShortcutsWindowController!.showWindow(self)
|
||||
}
|
||||
|
||||
|
||||
@IBAction func toggleInspectorWindow(_ sender: Any?) {
|
||||
|
||||
if inspectorWindowController == nil {
|
||||
inspectorWindowController = InspectorWindowController()
|
||||
}
|
||||
|
||||
if inspectorWindowController!.isOpen {
|
||||
inspectorWindowController!.window!.performClose(self)
|
||||
}
|
||||
else {
|
||||
inspectorWindowController!.showWindow(self)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func importOPMLFromFile(_ sender: AnyObject) {
|
||||
|
||||
let panel = NSOpenPanel()
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="13526" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="13770" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13526"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13770"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Application-->
|
||||
@ -457,6 +457,11 @@
|
||||
<action selector="showMainWindow:" target="Ady-hI-5gd" id="TY8-J6-NUD"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Info" keyEquivalent="i" id="24r-2i-fXR">
|
||||
<connections>
|
||||
<action selector="toggleInspectorWindow:" target="Ady-hI-5gd" id="Bw5-4R-iWP"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Feed Directory" id="iDZ-cW-hZ0">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
|
@ -150,6 +150,11 @@
|
||||
84CFF56D1AC3D20A00CEA6C8 /* NSImage+RSCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 84CFF56B1AC3D20A00CEA6C8 /* NSImage+RSCore.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
84CFF56E1AC3D20A00CEA6C8 /* NSImage+RSCore.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CFF56C1AC3D20A00CEA6C8 /* NSImage+RSCore.m */; };
|
||||
84E34DA61F9FA1070077082F /* UndoableCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E34DA51F9FA1070077082F /* UndoableCommand.swift */; };
|
||||
84E72E151FBD647500B873C1 /* InspectorItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E72E101FBD647500B873C1 /* InspectorItem.swift */; };
|
||||
84E72E161FBD647500B873C1 /* InspectorItemContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E72E111FBD647500B873C1 /* InspectorItemContainerView.swift */; };
|
||||
84E72E171FBD647500B873C1 /* InspectorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E72E121FBD647500B873C1 /* InspectorView.swift */; };
|
||||
84E72E181FBD647500B873C1 /* InspectorWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84E72E131FBD647500B873C1 /* InspectorWindow.xib */; };
|
||||
84E72E191FBD647500B873C1 /* InspectorWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E72E141FBD647500B873C1 /* InspectorWindowController.swift */; };
|
||||
84F20F831F16BA6200D8E682 /* PropertyList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F20F821F16BA6200D8E682 /* PropertyList.swift */; };
|
||||
84FE9FC31C00453900081CE9 /* NSStoryboard+RSCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 84FE9FC11C00453900081CE9 /* NSStoryboard+RSCore.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
84FE9FC41C00453900081CE9 /* NSStoryboard+RSCore.m in Sources */ = {isa = PBXBuildFile; fileRef = 84FE9FC21C00453900081CE9 /* NSStoryboard+RSCore.m */; };
|
||||
@ -260,6 +265,11 @@
|
||||
84CFF56B1AC3D20A00CEA6C8 /* NSImage+RSCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSImage+RSCore.h"; sourceTree = "<group>"; };
|
||||
84CFF56C1AC3D20A00CEA6C8 /* NSImage+RSCore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSImage+RSCore.m"; sourceTree = "<group>"; };
|
||||
84E34DA51F9FA1070077082F /* UndoableCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = UndoableCommand.swift; path = RSCore/UndoableCommand.swift; sourceTree = "<group>"; };
|
||||
84E72E101FBD647500B873C1 /* InspectorItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InspectorItem.swift; sourceTree = "<group>"; };
|
||||
84E72E111FBD647500B873C1 /* InspectorItemContainerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InspectorItemContainerView.swift; sourceTree = "<group>"; };
|
||||
84E72E121FBD647500B873C1 /* InspectorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InspectorView.swift; sourceTree = "<group>"; };
|
||||
84E72E131FBD647500B873C1 /* InspectorWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = InspectorWindow.xib; sourceTree = "<group>"; };
|
||||
84E72E141FBD647500B873C1 /* InspectorWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InspectorWindowController.swift; sourceTree = "<group>"; };
|
||||
84F20F821F16BA6200D8E682 /* PropertyList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PropertyList.swift; sourceTree = "<group>"; };
|
||||
84FE9FC11C00453900081CE9 /* NSStoryboard+RSCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSStoryboard+RSCore.h"; sourceTree = "<group>"; };
|
||||
84FE9FC21C00453900081CE9 /* NSStoryboard+RSCore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSStoryboard+RSCore.m"; sourceTree = "<group>"; };
|
||||
@ -338,6 +348,7 @@
|
||||
8402047D1FBCE77900D94C1A /* BatchUpdate.swift */,
|
||||
84CFF5241AC3C8A200CEA6C8 /* Foundation */,
|
||||
84CFF5551AC3CF4A00CEA6C8 /* AppKit */,
|
||||
84E72E0F1FBD647500B873C1 /* Inspector */,
|
||||
84CFF5661AC3D13F00CEA6C8 /* Images */,
|
||||
84CFF4F81AC3C69700CEA6C8 /* Info.plist */,
|
||||
84CFF5031AC3C69700CEA6C8 /* RSCoreTests */,
|
||||
@ -462,6 +473,19 @@
|
||||
path = RSCore;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
84E72E0F1FBD647500B873C1 /* Inspector */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
84E72E131FBD647500B873C1 /* InspectorWindow.xib */,
|
||||
84E72E141FBD647500B873C1 /* InspectorWindowController.swift */,
|
||||
84E72E121FBD647500B873C1 /* InspectorView.swift */,
|
||||
84E72E111FBD647500B873C1 /* InspectorItemContainerView.swift */,
|
||||
84E72E101FBD647500B873C1 /* InspectorItem.swift */,
|
||||
);
|
||||
name = Inspector;
|
||||
path = RSCore/Inspector;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
@ -652,6 +676,7 @@
|
||||
files = (
|
||||
84C687301FBAA30800345C9E /* LogWindow.xib in Resources */,
|
||||
8479213C1FBA426B004AD08C /* WebViewWindow.xib in Resources */,
|
||||
84E72E181FBD647500B873C1 /* InspectorWindow.xib in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -713,6 +738,7 @@
|
||||
849BF8BA1C9130150071D1DA /* DiskSaver.swift in Sources */,
|
||||
84FE9FC41C00453900081CE9 /* NSStoryboard+RSCore.m in Sources */,
|
||||
84CFF5341AC3CB6800CEA6C8 /* NSDictionary+RSCore.m in Sources */,
|
||||
84E72E161FBD647500B873C1 /* InspectorItemContainerView.swift in Sources */,
|
||||
84CFF54C1AC3CDAC00CEA6C8 /* NSString+RSCore.m in Sources */,
|
||||
84CFF5171AC3C73000CEA6C8 /* RSConstants.m in Sources */,
|
||||
8432B1881DACA2060057D6DF /* NSWindow-Extensions.swift in Sources */,
|
||||
@ -739,6 +765,7 @@
|
||||
84CFF5611AC3D0CE00CEA6C8 /* RSBinaryCache.m in Sources */,
|
||||
84CFF5301AC3CB1900CEA6C8 /* NSDate+RSCore.m in Sources */,
|
||||
84CFF5281AC3C9A200CEA6C8 /* NSArray+RSCore.m in Sources */,
|
||||
84E72E171FBD647500B873C1 /* InspectorView.swift in Sources */,
|
||||
84CFF5591AC3CF9100CEA6C8 /* NSView+RSCore.m in Sources */,
|
||||
84CFF56A1AC3D1B000CEA6C8 /* RSScaling.m in Sources */,
|
||||
84FEB4AC1D19D7F4004727E5 /* Date+Extensions.swift in Sources */,
|
||||
@ -751,9 +778,11 @@
|
||||
844C915C1B65753E0051FC1B /* RSPlist.m in Sources */,
|
||||
84CFF5231AC3C89D00CEA6C8 /* NSObject+RSCore.m in Sources */,
|
||||
8414CBA71C95F2EA00333C12 /* Set+Extensions.swift in Sources */,
|
||||
84E72E191FBD647500B873C1 /* InspectorWindowController.swift in Sources */,
|
||||
84B99C9A1FAE650100ECDEDB /* OPMLRepresentable.swift in Sources */,
|
||||
84E34DA61F9FA1070077082F /* UndoableCommand.swift in Sources */,
|
||||
844F91D61D90D86100820C48 /* RSTransparentContainerView.m in Sources */,
|
||||
84E72E151FBD647500B873C1 /* InspectorItem.swift in Sources */,
|
||||
84CFF56E1AC3D20A00CEA6C8 /* NSImage+RSCore.m in Sources */,
|
||||
8453F7DF1BDF337800B1C8ED /* RSMacroProcessor.m in Sources */,
|
||||
842E45CC1ED623C7000A8B52 /* UniqueIdentifier.swift in Sources */,
|
||||
|
19
Frameworks/RSCore/RSCore/Inspector/InspectorItem.swift
Normal file
19
Frameworks/RSCore/RSCore/Inspector/InspectorItem.swift
Normal file
@ -0,0 +1,19 @@
|
||||
//
|
||||
// InspectorItem.swift
|
||||
// Evergreen
|
||||
//
|
||||
// Created by Brent Simmons on 11/15/17.
|
||||
// Copyright © 2017 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
protocol InspectorItem: class {
|
||||
|
||||
var localizedTitle: String { get }
|
||||
var view: NSView { get }
|
||||
var inspectedObjects: [Any]? { get set }
|
||||
var expanded: Bool { get set }
|
||||
|
||||
func canInspect(_ objects: [Any]) -> Bool
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
//
|
||||
// InspectorItemContainerView.swift
|
||||
// Evergreen
|
||||
//
|
||||
// Created by Brent Simmons on 11/15/17.
|
||||
// Copyright © 2017 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
|
||||
class InspectorItemContainerView: NSView {
|
||||
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
super.draw(dirtyRect)
|
||||
|
||||
// Drawing code here.
|
||||
}
|
||||
|
||||
}
|
29
Frameworks/RSCore/RSCore/Inspector/InspectorView.swift
Normal file
29
Frameworks/RSCore/RSCore/Inspector/InspectorView.swift
Normal file
@ -0,0 +1,29 @@
|
||||
//
|
||||
// InspectorView.swift
|
||||
// Evergreen
|
||||
//
|
||||
// Created by Brent Simmons on 11/15/17.
|
||||
// Copyright © 2017 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
// The content view for the window.
|
||||
//
|
||||
// InspectorWindow
|
||||
// InspectorView
|
||||
// InspectorItemContainerView
|
||||
// NSView (inspector item)
|
||||
// InspectorItemContainerView
|
||||
// NSView (inspector item)
|
||||
// etc.
|
||||
|
||||
class InspectorView: NSView {
|
||||
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
super.draw(dirtyRect)
|
||||
|
||||
// Drawing code here.
|
||||
}
|
||||
|
||||
}
|
27
Frameworks/RSCore/RSCore/Inspector/InspectorWindow.xib
Normal file
27
Frameworks/RSCore/RSCore/Inspector/InspectorWindow.xib
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13770" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13770"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="InspectorWindowController" customModule="RSCore" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="window" destination="xKZ-6p-7Rw" id="eII-Iv-tyT"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<window title="Inspector" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" tabbingMode="disallowed" id="xKZ-6p-7Rw" customClass="NSPanel">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" utility="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="272" y="172" width="276" height="378"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
|
||||
<view key="contentView" id="cBK-fp-tpk" customClass="InspectorView" customModule="RSCore" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="276" height="378"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</view>
|
||||
<point key="canvasLocation" x="171" y="-47"/>
|
||||
</window>
|
||||
</objects>
|
||||
</document>
|
@ -0,0 +1,23 @@
|
||||
//
|
||||
// InspectorWindowController.swift
|
||||
// Evergreen
|
||||
//
|
||||
// Created by Brent Simmons on 11/15/17.
|
||||
// Copyright © 2017 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
public class InspectorWindowController: NSWindowController {
|
||||
|
||||
public var isOpen: Bool {
|
||||
get {
|
||||
return isWindowLoaded && window!.isVisible
|
||||
}
|
||||
}
|
||||
|
||||
public convenience init() {
|
||||
|
||||
self.init(windowNibName: NSNib.Name(rawValue: "InspectorWindow"))
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct LogItem: Hashable {
|
||||
public struct LogItem {
|
||||
|
||||
public enum ItemType {
|
||||
case debug, notification, warning, error
|
||||
@ -17,19 +17,11 @@ public struct LogItem: Hashable {
|
||||
public let type: ItemType
|
||||
public let message: String
|
||||
public let date: Date
|
||||
public let hashValue: Int
|
||||
|
||||
public init(type: ItemType, message: String) {
|
||||
|
||||
self.type = type
|
||||
self.message = message
|
||||
let date = Date()
|
||||
self.date = date
|
||||
self.hashValue = message.hashValue + date.hashValue
|
||||
}
|
||||
|
||||
static public func ==(lhs: LogItem, rhs: LogItem) -> Bool {
|
||||
|
||||
return lhs.type == rhs.type && lhs.message == rhs.message && lhs.date == rhs.date
|
||||
self.date = Date()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user