2017-05-26 22:10:30 +02:00
|
|
|
//
|
2017-09-23 21:00:07 +02:00
|
|
|
// AppNotifications.swift
|
2017-05-26 22:22:31 +02:00
|
|
|
// Evergreen
|
2017-05-26 22:10:30 +02:00
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 8/30/15.
|
|
|
|
// Copyright © 2015 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2017-09-24 21:24:44 +02:00
|
|
|
import Cocoa
|
|
|
|
import Data
|
2017-05-26 22:10:30 +02:00
|
|
|
|
|
|
|
extension Notification.Name {
|
|
|
|
|
|
|
|
static let SidebarSelectionDidChange = Notification.Name("SidebarSelectionDidChangeNotification")
|
|
|
|
static let TimelineSelectionDidChange = Notification.Name("TimelineSelectionDidChangeNotification")
|
|
|
|
|
|
|
|
static let AppNavigationKeyPressed = Notification.Name("AppNavigationKeyPressedNotification")
|
2017-10-22 00:56:01 +02:00
|
|
|
|
|
|
|
static let UserDidAddFeed = Notification.Name("UserDidAddFeedNotification")
|
2017-11-06 05:31:50 +01:00
|
|
|
|
|
|
|
// Sent by DetailViewController when mouse hovers over link in web view.
|
|
|
|
static let MouseDidEnterLink = Notification.Name("MouseDidEnterLinkNotification")
|
|
|
|
static let MouseDidExitLink = Notification.Name("MouseDidExitLinkNotification")
|
2017-05-26 22:10:30 +02:00
|
|
|
}
|
|
|
|
|
2017-09-24 21:24:44 +02:00
|
|
|
extension Notification {
|
|
|
|
|
|
|
|
var appInfo: AppInfo? {
|
|
|
|
get {
|
|
|
|
return AppInfo.pullFromUserInfo(userInfo)
|
|
|
|
}
|
|
|
|
}
|
2017-09-19 07:00:35 +02:00
|
|
|
}
|
|
|
|
|
2017-09-24 21:24:44 +02:00
|
|
|
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?
|
2017-11-05 07:05:20 +01:00
|
|
|
var objects: [AnyObject]?
|
2017-10-22 00:56:01 +02:00
|
|
|
var feed: Feed?
|
2017-11-06 05:31:50 +01:00
|
|
|
var url: String?
|
2017-10-22 00:56:01 +02:00
|
|
|
|
2017-09-24 21:24:44 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2017-05-26 22:10:30 +02:00
|
|
|
|
|
|
|
|