mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-13 01:46:51 +01:00
66 lines
1.6 KiB
Swift
66 lines
1.6 KiB
Swift
//
|
|
// AppNotifications.swift
|
|
// Evergreen
|
|
//
|
|
// Created by Brent Simmons on 8/30/15.
|
|
// Copyright © 2015 Ranchero Software, LLC. All rights reserved.
|
|
//
|
|
|
|
import Cocoa
|
|
import Data
|
|
|
|
extension Notification.Name {
|
|
|
|
static let SidebarSelectionDidChange = Notification.Name("SidebarSelectionDidChangeNotification")
|
|
static let TimelineSelectionDidChange = Notification.Name("TimelineSelectionDidChangeNotification")
|
|
|
|
static let AppNavigationKeyPressed = Notification.Name("AppNavigationKeyPressedNotification")
|
|
|
|
static let UserDidAddFeed = Notification.Name("UserDidAddFeedNotification")
|
|
|
|
// Sent by DetailViewController when mouse hovers over link in web view.
|
|
static let MouseDidEnterLink = Notification.Name("MouseDidEnterLinkNotification")
|
|
static let MouseDidExitLink = Notification.Name("MouseDidExitLinkNotification")
|
|
}
|
|
|
|
extension Notification {
|
|
|
|
var appInfo: AppInfo? {
|
|
get {
|
|
return AppInfo.pullFromUserInfo(userInfo)
|
|
}
|
|
}
|
|
}
|
|
|
|
typealias UserInfoDictionary = [AnyHashable: Any]
|
|
|
|
final class AppInfo {
|
|
|
|
// These are things commonly passed around in Evergreen notifications.
|
|
// Rather than setting these things using strings, we have a single AppInfo class
|
|
// that the userInfo dictionary may contain.
|
|
|
|
var view: NSView?
|
|
var article: Article?
|
|
var articles: Set<Article>?
|
|
var navigationKey: Int?
|
|
var objects: [AnyObject]?
|
|
var feed: Feed?
|
|
var url: String?
|
|
|
|
static let appInfoKey = "appInfo"
|
|
|
|
var userInfo: UserInfoDictionary {
|
|
get {
|
|
return [AppInfo.appInfoKey: self] as UserInfoDictionary
|
|
}
|
|
}
|
|
|
|
static func pullFromUserInfo(_ userInfo: UserInfoDictionary?) -> AppInfo? {
|
|
|
|
return userInfo?[appInfoKey] as? AppInfo
|
|
}
|
|
}
|
|
|
|
|