-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds these services that can be invoked from any application's Services menu, and assigned keyboard shortcuts in the Keyboard panel of System Preferences: - Start Menubar Countdown - Stop Menubar Countdown - Pause Menubar Countdown - Resume Menubar Countdown
- Loading branch information
1 parent
704327f
commit 9e64014
Showing
5 changed files
with
159 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// ServicesProvider.swift | ||
// Menubar Countdown | ||
// | ||
// Copyright © 2019 Kristopher Johnson. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Cocoa | ||
|
||
/** | ||
Implements the Services menu items for the application. | ||
|
||
The provided services are | ||
|
||
- Start Countdown: show the start dialog | ||
- Stop Countdown: reset the timer | ||
- Pause Countdown: pause the timer | ||
- Resume Countdown: resume paused timer | ||
|
||
See also | ||
|
||
- The `NSServices` entries in `Info.plist` | ||
- Construction and registration of the service provider in `AppDelegate.applicationDidFinishLaunching()` | ||
|
||
*/ | ||
@objc class ServicesProvider: NSObject { | ||
|
||
private var appDelegate: AppDelegate | ||
|
||
init(appDelegate: AppDelegate) { | ||
self.appDelegate = appDelegate | ||
} | ||
|
||
/** | ||
Handle a Start Countdown service request. | ||
*/ | ||
@objc func startCountdown(_ pboard: NSPasteboard, userData: String, error: NSErrorPointer) { | ||
Log.debug("Start Countdown service was requested") | ||
appDelegate.showStartTimerDialog(self) | ||
} | ||
|
||
/** | ||
Handle a Stop Countdown service request. | ||
*/ | ||
@objc func stopCountdown(_ pboard: NSPasteboard, userData: String, error: NSErrorPointer) { | ||
Log.debug("Stop Countdown service was requested") | ||
appDelegate.stopTimer(self) | ||
} | ||
|
||
/** | ||
Handle a Pause Countdown service request. | ||
*/ | ||
@objc func pauseCountdown(_ pboard: NSPasteboard, userData: String, error: NSErrorPointer) { | ||
Log.debug("Pause Countdown service was requested") | ||
appDelegate.pauseTimer(self) | ||
} | ||
|
||
/** | ||
Handle a Resume Countdown service request. | ||
*/ | ||
@objc func resumeCountdown(_ pboard: NSPasteboard, userData: String, error: NSErrorPointer) { | ||
Log.debug("Resume Countdown service was requested") | ||
appDelegate.resumeTimer(self) | ||
} | ||
} |