-
Notifications
You must be signed in to change notification settings - Fork 2
files core monitor pkwidgettouchbaritem swift 3f0e6ed0
ventaphobia edited this page Apr 23, 2026
·
1 revision
- Area: Touch Bar and Pock widget runtime.
- This page records the file's current repository role, source metadata, and recent commit history.
- Review nearby tests and commit pages before changing this file.
| Field | Value |
|---|---|
| Source path | Core-Monitor/PKWidgetTouchBarItem.swift |
| Wiki area | Touch Bar and Pock widget runtime |
| Exists in current checkout | True |
| Size | 3867 bytes |
| Binary | False |
| Line count | 108 |
| Extension | .swift |
AppKit
| Kind | Name | Line |
|---|---|---|
| class | PKWidgetTouchBarItem |
2 |
| extension | NSView |
81 |
| func | touchBarSnapshotImage |
83 |
| Commit | Date | Subject |
|---|---|---|
679aae6 |
2026-04-12 | changes. |
011232b |
2026-04-11 | Update website install video |
- Prefer focused changes that respect the ownership described above.
- If this file touches helper trust, SMC writes, startup, or permissions, update the relevant support docs and tests.
- If this file is generated or an asset manifest, verify the producing workflow instead of hand-editing generated payloads.
import AppKit
internal final class PKWidgetTouchBarItem: NSCustomTouchBarItem {
internal private(set) var widget: PKWidget?
override var customizationLabel: String! {
get { widget?.customizationLabel }
set { widget?.customizationLabel = newValue ?? "Widget" }
}
convenience init?(widget: PKWidgetInfo) {
self.init(widget: widget, identifier: NSTouchBarItem.Identifier(widget.bundleIdentifier))
}
convenience init?(widget: PKWidgetInfo, identifier: NSTouchBarItem.Identifier) {
guard let clss = widget.principalClass as? PKWidget.Type else {
return nil
}
self.init(identifier: identifier)
self.widget = clss.init()
self.widget?.customizationLabel = widget.name
viewController = PKWidgetViewController(item: self)
}
private var defaultSnapshotView: NSView {
let container = NSView(frame: NSRect(x: 0, y: 0, width: 140, height: TB.stripH))
container.wantsLayer = true
container.layer?.backgroundColor = NSColor(calibratedWhite: 0.18, alpha: 1).cgColor
container.layer?.cornerRadius = TB.pillRadius
container.layer?.masksToBounds = true
let imageView = NSImageView(frame: NSRect(x: 12, y: 6, width: 18, height: 18))
imageView.imageScaling = .scaleProportionallyUpOrDown
imageView.image = NSImage(systemSymbolName: "square.grid.2x2", accessibilityDescription: nil)?
.withSymbolConfiguration(NSImage.SymbolConfiguration(pointSize: 14, weight: .medium))
imageView.contentTintColor = .white
let label = NSTextField(labelWithString: widget?.customizationLabel ?? "Widget")
label.font = NSFont.systemFont(ofSize: 10, weight: .semibold)
- Home
- Start Here
- Product Overview
- Runtime Architecture
- Monitoring Pipeline
- Fan Control
- Privileged Helper
- Touch Bar
- Release Automation
- Security Model
- File Index (279)
- Every Commit (401)
- Chronological Change Log
- Removed Parts
- All Deleted Paths
- Branches And Tags
- Wiki Manifest
- Start Here
- Product Overview
- Source Map
- Runtime Architecture
- App Startup And Lifecycle
- Dashboard Architecture
- Menu Bar Architecture
- Monitoring Pipeline
- Snapshot Trends And Freshness
- CPU GPU Memory Disk Network
- Battery Power And Thermals
- SMC And Apple Silicon
- Fan Control
- Custom Fan Curves
- Privileged Helper
- XPC Trust Boundary
- Helper Diagnostics
- Touch Bar Architecture
- Touch Bar Customization
- Weather And Location
- Privacy And Permissions
- Onboarding And Help
- Legacy Alerts
- Kernel Panic Weird Mode